/*-------------------------------------------------------------------------------*/
/*------- The Heterogeneous Effects of Monetary Policy on Labor Income: ---------*/
/*-------     Disentangling the Extensive and Intensive Margins         ---------*/
/*-------  This code produces the main Tables and Figures of the paper  ---------*/
/*-------------------------------------------------------------------------------*/

drop _all
clear matrix
global DIR "C:\Replication package"
cd "${DIR}"

use "FINAL_DATABASE.dta", clear
set httpproxy on

*** Define sample considered: 2007-2019
drop if year<2007

*---------------------------*
*----- Data processing -----*
*---------------------------*

xtset id year
sum total_after_tax, det
rename *income* *inc*
rename *labour* *labor*

*** Define labor income without self-employed
gen labor_w_inc = PY010N

*** Define labor income with unemployment benefits
replace PY090N = 0 if PY090N==.
gen labor_ub_inc = PY010N + PY050N + PY090N

*** Deflating income
bysort year: egen mean_inc = mean(total_after_tax)
gen mean_inc_def = mean_inc/ipch_2018
*tsline mean_inc mean_inc_def
//
gen labor_inc_def = labor_inc/ipch_2018
gen labor_w_inc_def = labor_w_inc/ipch_2018
gen labor_ub_inc_def = labor_ub_inc/ipch_2018
gen total_after_tax_def = total_after_tax/ipch_2018

***  labour Force (employed or unemployed) - Situation Actif (emploi + chomage)
replace actif = 0 if actif==2

xtset id year
bysort id: gen situa_actif = 0
replace situa_actif = 1 if (situa_new==1 | situa_new==2 | situa_new==4) 
replace situa_actif = 1 if (L.situa_new==1 | situa_new==2 | L.situa_new==4) & L.id==id
replace situa_actif = 1 if (F.situa_new==1 | situa_new==2 | F.situa_new==4) & F.id==id
tab situa_actif

gen situa_revsal = 0
replace situa_revsal = 1 if labor_inc_def!=0
replace situa_revsal = 1 if L.labor_inc_def!=0 & L.id==id
replace situa_revsal = 1 if F.labor_inc_def!=0 & F.id==id
replace situa_revsal = 1 if situa_new==4
replace situa_revsal = 1 if L.situa_new==4 & L.id==id
replace situa_revsal = 1 if F.situa_new==4 & F.id==id
tab situa_revsal

*** Benchmark labor income
gen base_income = .
replace base_income = L.labor_inc_def
replace base_income = L2.labor_inc_def if L.labor_inc_def==.

*** Benchmark labor income with UB
gen base_ub_income = .
replace base_ub_income = L.labor_ub_inc_def
replace base_ub_income = L2.labor_ub_inc_def if L.labor_ub_inc_def==.

*** Benchmark labor income without self-employed
gen base_w_income = .
replace base_w_income = L.labor_w_inc_def
replace base_w_income = L2.labor_w_inc_def if L.labor_w_inc_def==.

*** Benchmark labor income with t-2
gen base_income_t2 = .
replace base_income_t2 = L2.labor_inc_def

*** Benchmark labor income - lifetime earnings up to t_1
cap drop base_income_prev
gen base_income_prev = .
forvalues i = 2007(1)2019 {
egen temp = mean(labor_inc_def) if year<`i', by(id)
replace base_income_prev = L.temp if year==`i'
replace base_income_prev = L2.temp if year==`i' & L.temp==.
drop *temp*
}

*** Deciles
sum labor_inc_def if situa_actif==1
sum labor_inc_def if situa_actif==1 & L.labor_inc_def!=.
sum labor_inc_def if situa_actif==1 & base_income!=.
xtset id year
xtile decile_actif = base_income if situa_actif==1, nq(10)
tab decile_actif

xtset id year
xtile decile_w_inc = base_w_income if situa_actif==1, nq(10)
tab decile_w_inc

xtset id year
xtile decile_ub_inc = base_ub_income if situa_actif==1, nq(10)
tab decile_ub_inc

xtset id year
xtile decile_revsal = base_income if situa_revsal==1, nq(10)
tab decile_revsal

xtset id year
xtile decile_t2 = base_income_t2 if situa_actif==1, nq(10)
tab decile_t2

xtset id year
xtile decile_lt_prev = base_income_prev if situa_actif==1, nq(10)
tab decile_lt_prev

*** Quintiles
xtile quintile = base_income if situa_actif==1, nq(5)
tab quintile

*** Labor income changes
xtset id year
bysort id: gen ACt2labor = L.labor_inc_def - L2.labor_inc_def
replace ACt2labor = . if decile_t2==.
bysort id: gen AC0labor = labor_inc_def - base_income
replace AC0labor = . if decile_actif==.
bysort id: gen AC1labor = F1.labor_inc_def - base_income
replace AC1labor = . if decile_actif==.
bysort id: gen AC2labor = F2.labor_inc_def - base_income
replace AC2labor = . if decile_actif==.
//
bysort id: gen AC0labor_g = (labor_inc_def - base_income)/base_income*100
replace AC0labor_g = . if decile_actif==.

*** Labor income (without self-employed) changes
xtset id year
bysort id: gen AC0labor_w = labor_w_inc_def - base_w_income
replace AC0labor_w = . if decile_w_inc==.

*** Labor income (with UB) changes
xtset id year
bysort id: gen AC0labor_ub = labor_ub_inc_def - base_ub_income
replace AC0labor_ub = . if decile_ub_inc==.

*** "Normal" growth rate of labor income (with UB)
xtset id year
bysort id: gen RC0labor_ub = (labor_ub_inc_def - base_ub_income)/base_ub_income*100
replace RC0labor_ub = . if decile_ub_inc==.

*** Davies-Haltiwanger Labor income changes
xtset id year
bysort id: gen DH0labor = (labor_inc_def - base_income)/((labor_inc_def + base_income)/2)*100
replace DH0labor = . if decile_actif==.

*** Dimensions du panel
xtset id year
xtdes 
tsspell id 
egen length = max(_seq), by(id _spell)
sum length, detail
gen sample_panel = 1
replace sample_panel = 0 if length<2
sum length if sample_panel==1, detail

*** Layoff probability
gen prob_layoff = .
replace prob_layoff = 1 if perdre==2
replace prob_layoff = 0 if ((perdre==1 | perdre>2) & perdre!=.)

*** Age
gen age16_24=0
gen age25_34=0
gen age35_44=0
gen age45_54=0
gen age55_64=0
gen age65_over=0
replace age16_24=1 if age<=24
replace age25_34=1 if age>24 & age<=34
replace age35_44=1 if age>34 & age<=44
replace age45_54=1 if age>44 & age<=54
replace age55_64=1 if age>54 & age<=64
replace age65_over=1 if age>64
tab age

*** Occupation
cap drop occupation
gen occupation = .
replace occupation = 1 if classif==7 | classif==4 | classif==8 // CatA/B/C
replace occupation = 2 if classif==1 | classif==2 | classif==3 | classif==9 // Ouv1/Ouv2/Tech/Emp 
replace occupation = 3 if classif==5 // NonCadre
replace occupation = 4 if classif==7 | classif==6 | classif==10 // Cadre/DG
replace occupation = 99 if classif==. // Missing
tab occupation

*** Type Contrat
cap drop typecontrat
gen typecontrat = .
replace typecontrat = 1 if contrat==1 | contrat==3 | contrat==4 // App/Stag/Qual
replace typecontrat = 2 if contrat==2 // Interim
replace typecontrat = 3 if contrat==5 // CDD
replace typecontrat = 4 if contrat==6 // CDI
replace typecontrat = 99 if contrat==. // Missing
tab typecontrat

*** Removing outliers
cap drop nooutlier AC0labor_p1 AC0labor_p99
sum AC0labor, det
bysort year: egen AC0labor_p1 = pctile(AC0labor), p(1)
bysort year: egen AC0labor_p99 = pctile(AC0labor), p(99)
gen nooutlier = 1
replace nooutlier = 0 if (AC0labor<AC0labor_p1 | AC0labor>AC0labor_p99)

*** Our sample
cap drop sample
gen sample = .
replace sample = 1 if AC0labor!=. &  AC1labor!=. & nooutlier==1
tab sample

*** With outliers
cap drop sample2
gen sample2 = .
replace sample2 = 1 if AC0labor!=. &  AC1labor!=.

*** With winsorized outliers
gen AC0labor_win = AC0labor
replace AC0labor_win = AC0labor_p1 if AC0labor<=AC0labor_p1
replace AC0labor_win = AC0labor_p99 if AC0labor>=AC0labor_p99 & AC0labor!=.

bysort year: egen AC1labor_p1 = pctile(AC1labor), p(1)
bysort year: egen AC1labor_p99 = pctile(AC1labor), p(99)
gen AC1labor_win = AC1labor
replace AC1labor_win = AC1labor_p1 if AC1labor<=AC1labor_p1
replace AC1labor_win = AC1labor_p99 if AC1labor>=AC1labor_p99 & AC1labor!=.

bysort year: egen AC2labor_p1 = pctile(AC2labor), p(1)
bysort year: egen AC2labor_p99 = pctile(AC2labor), p(99)
gen AC2labor_win = AC2labor
replace AC2labor_win = AC2labor_p1 if AC2labor<=AC2labor_p1
replace AC2labor_win = AC2labor_p99 if AC2labor>=AC2labor_p99 & AC2labor!=.

*** Individuals changing sector
sort id year
cap drop changing_sector changing_sector_dum
gen changing_sector = 0
by id: replace changing_sector = 1 if sector!=L.sector & NAF2_new[_n-1]!="MISS"
by id: replace changing_sector = 0 if NAF2_new=="MISS"
tab changing_sector if sample==1


***********************************************
*** Inputs for APPENDIX TABLE A1 - STAT DES ***
***********************************************

gen labor_share = labor_inc/total_pre_tax
egen total_labor_inc = total(labor_inc_def) if decile_actif!=. & sample==1
//
egen total_labor_inc_b50 = total(labor_inc_def) if decile_actif<=5 & sample==1
egen total_labor_inc_mm40 = total(labor_inc_def) if decile_actif>=6 & decile_actif<=9 & sample==1
egen total_labor_inc_t10 = total(labor_inc_def) if decile_actif>=10 & decile_actif!=. & sample==1
format total_labor_inc %12.0f
format total_labor_inc_b50 %12.0f
gen share_b50 = total_labor_inc_b50/total_labor_inc if decile_actif<=5 & sample==1
gen share_mm40 = total_labor_inc_mm40/total_labor_inc if decile_actif>=6 & decile_actif<=9 & sample==1
gen share_t10 = total_labor_inc_t10/total_labor_inc if decile_actif>=10 & decile_actif!=. & sample==1
//
egen total_labor_inc_b40 = total(labor_inc_def) if decile_actif<=4 & sample==1
egen total_labor_inc_m40 = total(labor_inc_def) if decile_actif>=5 & decile_actif<=8 & sample==1
egen total_labor_inc_t20 = total(labor_inc_def) if decile_actif>=9 & decile_actif!=. & sample==1
format total_labor_inc %12.0f
format total_labor_inc_b40 %12.0f
gen share_b40 = total_labor_inc_b40/total_labor_inc if decile_actif<=4 & sample==1
gen share_m40 = total_labor_inc_m40/total_labor_inc if decile_actif>=5 & decile_actif<=8 & sample==1
gen share_t20 = total_labor_inc_t20/total_labor_inc if decile_actif>=9 & decile_actif!=. & sample==1

*** Quintiles
sum base_income age sex if quintile==1 & sample==1
sum base_income age sex if quintile==2 & sample==1
sum base_income age sex if quintile==3 & sample==1
sum base_income age sex if quintile==4 & sample==1
sum base_income age sex if quintile==5 & sample==1

egen total_labor_inc_q1 = total(labor_inc_def) if quintile==1 & sample==1
egen total_labor_inc_q2 = total(labor_inc_def) if quintile==2 & sample==1
egen total_labor_inc_q3 = total(labor_inc_def) if quintile==3 & sample==1
egen total_labor_inc_q4 = total(labor_inc_def) if quintile==4 & sample==1
egen total_labor_inc_q5 = total(labor_inc_def) if quintile==5 & sample==1
gen share_q1 = total_labor_inc_q1/total_labor_inc if quintile==1 & sample==1
gen share_q2 = total_labor_inc_q2/total_labor_inc if quintile==2 & sample==1
gen share_q3 = total_labor_inc_q3/total_labor_inc if quintile==3 & sample==1
gen share_q4 = total_labor_inc_q4/total_labor_inc if quintile==4 & sample==1
gen share_q5 = total_labor_inc_q5/total_labor_inc if quintile==5 & sample==1
sum share_q1
sum share_q2
sum share_q3
sum share_q4
sum share_q5

*** Three groups
sum base_income age sex if decile_actif!=. & sample==1
sum base_income age sex if decile_actif<=4 & sample==1
sum base_income age sex if decile_actif>=5 & decile_actif<=8 & sample==1
sum base_income age sex if decile_actif>=9 & decile_actif!=. & sample==1
//
sum share_b40 if sample==1 & decile_actif<=5
sum share_m40 if sample==1 & decile_actif>=6 & decile_actif<=9
sum share_t20 if sample==1 & decile_actif>=10 & decile_actif!=.

*****************************************************
*** INPUT FOR APPENDIX TABLE A2 - SRCV VALIDATION ***
*****************************************************

*** For comparison with ERFS 2016 
xtile decile_labor_inc = labor_inc if year==2016 & sample2==1, nq(10)
sum labor_inc if year==2016 & sample2==1 & decile_labor_inc<=5
sum labor_inc if year==2016 & sample2==1 & decile_labor_inc>=6 & decile_labor_inc<=9
sum labor_inc if year==2016 & sample2==1 & decile_labor_inc>=10 & decile_labor_inc!=.

*** For comparison with WID 
sum share_b50 if sample==1 & decile_actif<=5
sum share_mm40 if sample==1 & decile_actif>=6 & decile_actif<=9
sum share_t10 if sample==1 & decile_actif>=10 & decile_actif!=.


***----- Monetary policy shocks: sign and normalization -----***

cap drop mp_shock mp_shock1
egen mp_shock1 = std(jk19_mpsign)
gen mp_shock = -1*mp_shock1
sum jk19_mpsign mp_shock1 mp_shock 
//
egen mp_shock2 = std(jk19_mpsign_w)
gen mp_shock_w = -1*mp_shock2


***----- For Intensive/Extensive -----***
xtset id year

*** Benchmark chomage status
gen base_chomage = .
replace base_chomage = 0 if L1.situa_new!=4 & L1.id==id
replace base_chomage = 0 if L2.situa_new!=4 & L1.situa_new==. & L2.id==id
replace base_chomage = 1 if L1.situa_new==4 & L1.id==id
replace base_chomage = 1 if L2.situa_new==4 & L1.situa_new==. & L2.id==id

*** Dchomage
gen chomage = 0
replace chomage = 1 if situa_new==4
gen Dchomage = (chomage - base_chomage)*100

*** Stat des
sum chomage if decile_actif!=. & sample==1
sum chomage if decile_actif<=4 & sample==1
sum chomage if decile_actif>=5 & decile_actif<=8 & sample==1
sum chomage if decile_actif>=9 & decile_actif!=. & sample==1

*** Employed
gen employed = 0
replace employed = 1 if decile_actif!=. & (situa_new==1&L.situa_new==1) & (nbmois_cho==0&L.nbmois_cho==0) ///
& (labor_inc_def!=0&base_income!=0) & L.id==id


*--------------------------------------------------------------------------*
*--------------------------------------------------------------------------*
*----------------- SECTION 3: MP effects on labor income  -----------------*
*--------------------------------------------------------------------------*
*--------------------------------------------------------------------------*

*** TABLE 1 - Panel A 
eststo clear
eststo: quiet reg AC0labor mp_shock if decile_actif!=. & sample==1, vce(clus id)
eststo: quiet reg AC0labor mp_shock if decile_actif<=4 & sample==1, vce(clus id)
eststo: quiet reg AC0labor mp_shock if decile_actif>=5 & decile_actif<=8 & sample==1, vce(clus id)
eststo: quiet reg AC0labor mp_shock if decile_actif>=9 & decile_actif!=. & sample==1, vce(clus id)
esttab, nocons compress keep(mp_shock) star(** 0.05 *** 0.01)
esttab using Tab1a.tex, b(1) t(2) br noeqlines nogaps nolines nocons compress ///
keep(mp_shock) stats(N) star(** 0.05 *** 0.01) replace

*** In % of average income
sum base_income if decile_actif!=. & sample==1 
global mean_all = r(mean)
disp $mean_all
sum base_income if decile_actif<=4 & sample==1
global mean_b40 = r(mean)
disp $mean_b40
sum base_income if decile_actif>=5 & decile_actif<=8 & sample==1
global mean_m40 = r(mean)
disp $mean_m40
sum base_income if decile_actif>=9 & decile_actif!=. & sample==1
global mean_t20 = r(mean)
disp $mean_t20
cap drop AC0labor_all AC0labor_b40 AC0labor_m40 AC0labor_t20
gen AC0labor_all = AC0labor*100/$mean_all if decile_actif!=. & sample==1
gen AC0labor_b40 = AC0labor*100/$mean_b40 if decile_actif<=4 & sample==1
gen AC0labor_m40 = AC0labor*100/$mean_m40 if decile_actif>=5 & decile_actif<=8 & sample==1
gen AC0labor_t20 = AC0labor*100/$mean_t20 if decile_actif>=9 & decile_actif!=. & sample==1

*** TABLE 1 - Panel B - SCALED
eststo clear
eststo All: quiet reg AC0labor_all mp_shock if decile_actif!=. & sample==1, vce(clus id)
eststo B40: quiet reg AC0labor_b40 mp_shock if decile_actif<=4 & sample==1, vce(clus id)
eststo M40: quiet reg AC0labor_m40 mp_shock if decile_actif>=5 & decile_actif<=8 & sample==1, vce(clus id)
eststo T20: quiet reg AC0labor_t20 mp_shock if decile_actif>=9 & decile_actif!=. & sample==1, vce(clus id)
esttab All B40 M40 T20, nocons compress keep(mp_shock) star(** 0.05 *** 0.01)
esttab using Tab1b.tex, b(3) t(2) br noeqlines nogaps nolines nocons compress ///
keep(mp_shock) stats(N) star(** 0.05 *** 0.01) replace


*****************************************
***** APPENDIX TABLE A3 - Quintiles *****
*****************************************

*** Earnings
sum base_income if quintile!=. & sample==1
global mean_all = r(mean)
sum base_income if quintile==1 & sample==1
global mean_q1 = r(mean)
sum base_income if quintile==2 & sample==1
global mean_q2 = r(mean)
sum base_income if quintile==3 & sample==1
global mean_q3 = r(mean)
sum base_income if quintile==4 & sample==1
global mean_q4 = r(mean)
sum base_income if quintile==5 & sample==1
global mean_q5 = r(mean)
cap drop AC0labor_all 
gen AC0labor_all = AC0labor*100/$mean_all if quintile!=. & sample==1
gen AC0labor_q1 = AC0labor*100/$mean_q1 if quintile==1 & sample==1
gen AC0labor_q2 = AC0labor*100/$mean_q2 if quintile==2 & sample==1
gen AC0labor_q3 = AC0labor*100/$mean_q3 if quintile==3 & sample==1
gen AC0labor_q4 = AC0labor*100/$mean_q4 if quintile==4 & sample==1
gen AC0labor_q5 = AC0labor*100/$mean_q5 if quintile==5 & sample==1
// ALL
eststo clear
eststo: quiet reg AC0labor_all mp_shock if quintile!=. & sample==1, vce(clus id)
eststo: quiet reg AC0labor_q1 mp_shock if quintile==1 & sample==1, vce(clus id)
eststo: quiet reg AC0labor_q2 mp_shock if quintile==2 & sample==1, vce(clus id)
eststo: quiet reg AC0labor_q3 mp_shock if quintile==3 & sample==1, vce(clus id)
eststo: quiet reg AC0labor_q4 mp_shock if quintile==4 & sample==1, vce(clus id)
eststo: quiet reg AC0labor_q5 mp_shock if quintile==5 & sample==1, vce(clus id)
esttab, nocons compress keep(mp_shock) star(** 0.05 *** 0.01)
esttab using TabA3a.tex, b(3) t(2) br noeqlines nogaps nolines nocons compress ///
keep(mp_shock) stats(N) star(** 0.05 *** 0.01) replace

*** Unemployment
eststo clear
eststo: quiet reg Dchomage mp_shock if quintile!=. & sample==1, vce(clus id)
eststo: quiet reg Dchomage mp_shock if quintile==1 & sample==1, vce(clus id)
eststo: quiet reg Dchomage mp_shock if quintile==2 & sample==1, vce(clus id)
eststo: quiet reg Dchomage mp_shock if quintile==3 & sample==1, vce(clus id)
eststo: quiet reg Dchomage mp_shock if quintile==4 & sample==1, vce(clus id)
eststo: quiet reg Dchomage mp_shock if quintile==5 & sample==1, vce(clus id)
esttab, nocons compress keep(mp_shock) star(** 0.05 *** 0.01)
esttab using TabA3b.tex, b(3) t(2) br noeqlines nogaps nolines nocons compress ///
keep(mp_shock) stats(N) star(** 0.05 *** 0.01) replace


*************************************************
*** Footnote 10 - JK20 MP Poor's man approach ***
*************************************************
cap drop mp_shock mp_shock1
egen mp_shock1 = std(jk19_mppoor)
gen mp_shock = -1*mp_shock1
//
eststo clear
eststo All: quiet reg AC0labor_all mp_shock if decile_actif!=. & sample==1, vce(clus id)
eststo B40: quiet reg AC0labor_b40 mp_shock if decile_actif<=4 & sample==1, vce(clus id)
eststo M40: quiet reg AC0labor_m40 mp_shock if decile_actif>=5 & decile_actif<=8 & sample==1, vce(clus id)
eststo T20: quiet reg AC0labor_t20 mp_shock if decile_actif>=9 & decile_actif!=. & sample==1, vce(clus id)
esttab All B40 M40 T20, nocons compress keep(mp_shock) star(** 0.05 *** 0.01)
//
cap drop mp_shock mp_shock1
egen mp_shock1 = std(jk19_mpsign)
gen mp_shock = -1*mp_shock1


************************************************
******** TABLE A7 - DYNAMIC EFFECTS ************
************************************************

*** Income change from t-2 to t-1
sum base_income_t2 if decile_t2!=. & sample==1  
global mean_all = r(mean)
sum base_income_t2 if decile_t2<=4 & sample==1  
global mean_b40 = r(mean)
sum base_income_t2 if decile_t2>=5 & decile_t2<=8 & sample==1  
global mean_m40 = r(mean)
sum base_income_t2 if decile_t2>=9 & decile_t2!=. & sample==1  
global mean_t20 = r(mean)
cap drop AC0labor_all AC0labor_b40 AC0labor_m40 AC0labor_t20
gen AC0labor_all = ACt2labor*100/$mean_all if decile_t2!=. & sample==1  
gen AC0labor_b40 = ACt2labor*100/$mean_b40 if decile_t2<=4 & sample==1 
gen AC0labor_m40 = ACt2labor*100/$mean_m40 if decile_t2>=5 & decile_t2<=8 & sample==1  
gen AC0labor_t20 = ACt2labor*100/$mean_t20 if decile_t2>=9 & decile_t2!=. & sample==1  
//
eststo clear
eststo All: quiet reg AC0labor_all mp_shock if decile_t2!=. & sample==1, vce(clus id)
eststo B40: quiet reg AC0labor_b40 mp_shock if decile_t2<=4 & sample==1, vce(clus id)
eststo M40: quiet reg AC0labor_m40 mp_shock if decile_t2>=5 & decile_t2<=8 & sample==1, vce(clus id)
eststo T20: quiet reg AC0labor_t20 mp_shock if decile_t2>=9 & decile_t2!=. & sample==1, vce(clus id)
esttab All B40 M40 T20, nocons compress keep(mp_shock) star(** 0.05 *** 0.01)
esttab using TabA7a.tex, b(3) t(2) br noeqlines nogaps nolines nocons compress ///
keep(mp_shock) stats(N) star(** 0.05 *** 0.01) replace

*** Income changes from t-1 to t (baseline)
sum base_income if decile_actif!=. & sample==1 
global mean_all = r(mean)
sum base_income if decile_actif<=4 & sample==1
global mean_b40 = r(mean)
sum base_income if decile_actif>=5 & decile_actif<=8 & sample==1
global mean_m40 = r(mean)
sum base_income if decile_actif>=9 & sample==1
global mean_t20 = r(mean)
cap drop AC0labor_all AC0labor_b40 AC0labor_m40 AC0labor_t20
gen AC0labor_all = AC0labor*100/$mean_all if decile_actif!=. & sample==1
gen AC0labor_b40 = AC0labor*100/$mean_b40 if decile_actif<=4 & sample==1
gen AC0labor_m40 = AC0labor*100/$mean_m40 if decile_actif>=5 & decile_actif<=8 & sample==1
gen AC0labor_t20 = AC0labor*100/$mean_t20 if decile_actif>=9 & sample==1
//
eststo clear
eststo All: quiet reg AC0labor_all mp_shock if decile_actif!=. & sample==1, vce(clus id)
eststo B40: quiet reg AC0labor_b40 mp_shock if decile_actif<=4 & sample==1, vce(clus id)
eststo M40: quiet reg AC0labor_m40 mp_shock if decile_actif>=5 & decile_actif<=8 & sample==1, vce(clus id)
eststo T20: quiet reg AC0labor_t20 mp_shock if decile_actif>=9 & sample==1, vce(clus id)
esttab All B40 M40 T20, nocons compress keep(mp_shock) star(** 0.05 *** 0.01)
esttab using TabA7b.tex, b(3) t(2) br noeqlines nogaps nolines nocons compress ///
keep(mp_shock) stats(N) star(** 0.05 *** 0.01) replace


*** Income changes from t-1 to t+1
sum base_income if decile_actif!=. & sample==1
global mean_all = r(mean)
sum base_income if decile_actif<=4 & sample==1
global mean_b40 = r(mean)
sum base_income if decile_actif>=5 & decile_actif<=8 & sample==1
global mean_m40 = r(mean)
sum base_income if decile_actif>=9 & sample==1
global mean_t20 = r(mean)
cap drop AC1labor_all AC1labor_b40 AC1labor_m40 AC1labor_t20
gen AC1labor_all = AC1labor*100/$mean_all if decile_actif!=. & sample==1
gen AC1labor_b40 = AC1labor*100/$mean_b40 if decile_actif<=4 & sample==1
gen AC1labor_m40 = AC1labor*100/$mean_m40 if decile_actif>=5 & decile_actif<=8 & sample==1
gen AC1labor_t20 = AC1labor*100/$mean_t20 if decile_actif>=9 & sample==1
//
eststo clear
eststo All: quiet reg AC1labor_all mp_shock if decile_actif!=. & sample==1, vce(clus id)
eststo B40: quiet reg AC1labor_b40 mp_shock if decile_actif<=4 & sample==1, vce(clus id)
eststo M40: quiet reg AC1labor_m40 mp_shock if decile_actif>=5 & decile_actif<=8 & sample==1, vce(clus id)
eststo T20: quiet reg AC1labor_t20 mp_shock if decile_actif>=9 & sample==1, vce(clus id)
esttab All B40 M40 T20, nocons compress keep(mp_shock) star(** 0.05 *** 0.01)
esttab using TabA7c.tex, b(3) t(2) br noeqlines nogaps nolines nocons compress ///
keep(mp_shock) stats(N) star(** 0.05 *** 0.01) replace

*** Income changes from t-1 to t+2
sum base_income if decile_actif!=.
global mean_all = r(mean)
sum base_income if decile_actif<=4
global mean_b40 = r(mean)
sum base_income if decile_actif>=5 & decile_actif<=8
global mean_m40 = r(mean)
sum base_income if decile_actif>=9 & decile_actif!=.
global mean_t20 = r(mean)
cap drop AC2labor_all AC2labor_b40 AC2labor_m40 AC2labor_t20
gen AC2labor_all = AC2labor*100/$mean_all if decile_actif!=.
gen AC2labor_b40 = AC2labor*100/$mean_b40 if decile_actif<=4
gen AC2labor_m40 = AC2labor*100/$mean_m40 if decile_actif>=5 & decile_actif<=8
gen AC2labor_t20 = AC2labor*100/$mean_t20 if decile_actif>=9 & decile_actif!=.
//
eststo clear
eststo All: quiet reg AC2labor_all mp_shock if decile_actif!=., vce(clus id)
eststo B40: quiet reg AC2labor_b40 mp_shock if decile_actif<=4, vce(clus id)
eststo M40: quiet reg AC2labor_m40 mp_shock if decile_actif>=5 & decile_actif<=8, vce(clus id)
eststo T20: quiet reg AC2labor_t20 mp_shock if decile_actif>=9 & decile_actif!=., vce(clus id)
esttab All B40 M40 T20, nocons compress keep(mp_shock) star(** 0.05 *** 0.01)
esttab using TabA7d.tex, b(3) t(2) br noeqlines nogaps nolines nocons compress ///
keep(mp_shock) stats(N) star(** 0.05 *** 0.01) replace


*-------------------------------------------------------------------------------------*
*----------- TABLE A5 - Comparaison other aggregate business cycle shocks ------------*
*-------------------------------------------------------------------------------------*

*** Aggregate wage dynamics
cap drop mean_labor_inc agg_earnings temp1 temp2
egen temp1 = mean(labor_inc_def) if situa_actif==1, by(year)
egen mean_labor_inc = mean(temp1), by(year)
xtset id year
gen temp2 = (mean_labor_inc - L.mean_labor_inc)/L.mean_labor_inc*100
egen agg_earnings = mean(temp2), by(year)
//
eststo clear
eststo All: quiet reg AC0labor_all agg_earnings if decile_actif!=. & sample==1, vce(clus id)
eststo B40: quiet reg AC0labor_b40 agg_earnings if decile_actif<=4 & sample==1, vce(clus id)
eststo M40: quiet reg AC0labor_m40 agg_earnings if decile_actif>=5 & decile_actif<=8 & sample==1, vce(clus id)
eststo T20: quiet reg AC0labor_t20 agg_earnings if decile_actif>=9 & decile_actif!=. & sample==1, vce(clus id)
esttab All B40 M40 T20, nocons compress keep(agg_earnings) star(** 0.05 *** 0.01)
esttab using TabA5.tex, b(3) t(2) br noeqlines nogaps nolines nocons compress ///
keep(agg_earnings) stats(N) star(** 0.05 *** 0.01) replace


*------------------------------------------*
*--------  TABLE A6 - Robustness  ---------* 
*------------------------------------------*

**** Baseline
eststo clear
eststo All: quiet reg AC0labor_all mp_shock if decile_actif!=. & sample==1, vce(clus id)
eststo Bottom40: quiet reg AC0labor_b40 mp_shock if decile_actif<=4 & sample==1, vce(clus id)
eststo Middle40: quiet reg AC0labor_m40 mp_shock if decile_actif>=5 & decile_actif<=8 & sample==1, vce(clus id)
eststo Top20: quiet reg AC0labor_t20 mp_shock if decile_actif>=9 & decile_actif!=. & sample==1, vce(clus id)
esttab All Bottom40 Middle40 Top20, nocons compress keep(mp_shock) star(** 0.05 *** 0.01)
esttab All Bottom40 Middle40 Top20 using TabA6_1.tex, b(3) t(2) br noeqlines nogaps nolines nocons compress keep(mp_shock) star(** 0.05 *** 0.01) replace

*** FE estimation + Individual-level controls
xtset id year
local controls i.age i.DIPLOME i.cs24 i.HX060 i.nivact_new i.occupation i.contrat fe_sector_*
eststo All_fe: quiet xtreg AC0labor_all mp_shock `controls' if decile_actif!=. & sample==1, fe vce(clus id)
eststo B40_fe: quiet xtreg AC0labor_b40 mp_shock `controls' if decile_actif<=4 & sample==1, fe vce(clus id)
eststo M40_fe: quiet xtreg AC0labor_m40 mp_shock `controls' if decile_actif>=5 & decile_actif<=8 & sample==1, fe vce(clus id)
eststo T20_fe: quiet xtreg AC0labor_t20 mp_shock `controls' if decile_actif>=9 & decile_actif!=. & sample==1, fe vce(clus id)
esttab *_fe, nocons compress keep(mp_shock) star(** 0.05 *** 0.01)
esttab *_fe using TabA6_2.tex, b(3) t(2) br noeqlines nogaps nolines nocons compress keep(mp_shock) star(** 0.05 *** 0.01) replace

*** With unemployment benefits
sum base_ub_income if decile_ub_inc!=. & sample==1
global mean_all = r(mean)
sum base_ub_income if decile_ub_inc<=5 & sample==1 
global mean_b40 = r(mean)
sum base_ub_income if decile_ub_inc>=6 & decile_ub_inc<=9 & sample==1
global mean_m40 = r(mean)
sum base_ub_income if decile_ub_inc==10 & sample==1
global mean_t20 = r(mean)
cap drop AC0labor_all_ub AC0labor_b40_ub AC0labor_m40_ub AC0labor_t20_ub
gen AC0labor_all_ub = AC0labor_ub*100/$mean_all if decile_ub_inc!=. & sample==1
gen AC0labor_b40_ub = AC0labor_ub*100/$mean_b40 if decile_ub_inc<=5 & sample==1
gen AC0labor_m40_ub = AC0labor_ub*100/$mean_m40 if decile_ub_inc>=6 & decile_ub_inc<=9 & sample==1
gen AC0labor_t20_ub = AC0labor_ub*100/$mean_t20 if decile_ub_inc==10 & sample==1
//
eststo All_ub: quiet reg AC0labor_all_ub mp_shock if decile_ub_inc!=. & sample==1, vce(clus id)
eststo B40_ub: quiet reg AC0labor_b40_ub mp_shock if decile_ub_inc<=5 & sample==1, vce(clus id)
eststo M40_ub: quiet reg AC0labor_m40_ub mp_shock if decile_ub_inc>=6 & decile_ub_inc<=9 & sample==1, vce(clus id)
eststo T20_ub: quiet reg AC0labor_t20_ub mp_shock if decile_ub_inc==10 & sample==1, vce(clus id)
esttab *_ub, nocons compress keep(mp_shock) star(** 0.05 *** 0.01)
esttab *_ub using TabA6_3.tex, b(3) t(2) br noeqlines nogaps nolines nocons compress keep(mp_shock) star(** 0.05 *** 0.01) replace

*** Without self-employed
sum base_w_income if decile_w_inc!=. & sample==1
global mean_all = r(mean)
sum base_w_income if decile_w_inc<=5 & sample==1 
global mean_b40 = r(mean)
sum base_w_income if decile_w_inc>=6 & decile_w_inc<=9 & sample==1
global mean_m40 = r(mean)
sum base_w_income if decile_w_inc==10 & sample==1
global mean_t20 = r(mean)
cap drop AC0labor_all_w AC0labor_b40_w AC0labor_m40_w AC0labor_t20_w
gen AC0labor_all_w = AC0labor_w*100/$mean_all if decile_w_inc!=. & sample==1
gen AC0labor_b40_w = AC0labor_w*100/$mean_b40 if decile_w_inc<=5 & sample==1
gen AC0labor_m40_w = AC0labor_w*100/$mean_m40 if decile_w_inc>=6 & decile_w_inc<=9 & sample==1
gen AC0labor_t20_w = AC0labor_w*100/$mean_t20 if decile_w_inc==10 & sample==1
//
eststo All_w: quiet reg AC0labor_all_w mp_shock if decile_w_inc!=. & sample==1, vce(clus id)
eststo B40_w: quiet reg AC0labor_b40_w mp_shock if decile_w_inc<=5 & sample==1, vce(clus id)
eststo M40_w: quiet reg AC0labor_m40_w mp_shock if decile_w_inc>=6 & decile_w_inc<=9 & sample==1, vce(clus id)
eststo T20_w: quiet reg AC0labor_t20_w mp_shock if decile_w_inc==10 & sample==1, vce(clus id)
esttab *_w, nocons compress keep(mp_shock) star(** 0.05 *** 0.01)
esttab *_w using TabA6_4.tex, b(3) t(2) br noeqlines nogaps nolines nocons compress keep(mp_shock) star(** 0.05 *** 0.01) replace

*** Arc-percent changes (Davies-Haltiwanger)
eststo All_dh: quiet reg DH0labor mp_shock if decile_actif!=. & sample==1, vce(clus id)
eststo B40_dh: quiet reg DH0labor mp_shock if decile_actif<=4 & sample==1, vce(clus id)
eststo M40_dh: quiet reg DH0labor mp_shock if decile_actif>=5 & decile_actif<=8 & sample==1, vce(clus id)
eststo T20_dh: quiet reg DH0labor mp_shock if decile_actif>=9 & decile_actif!=. & sample==1, vce(clus id)
esttab *_dh, nocons compress keep(mp_shock) star(** 0.05 *** 0.01)
esttab *_dh using TabA6_5.tex, b(3) t(2) br noeqlines nogaps nolines nocons compress keep(mp_shock) star(** 0.05 *** 0.01) replace

*** All individuals with nonmissing labor_income
sum base_income if decile_revsal!=. & sample==1
global mean_all = r(mean)
sum base_income if decile_revsal<=4 & sample==1 
global mean_b40 = r(mean)
sum base_income if decile_revsal>=5 & decile_revsal<=8 & sample==1
global mean_m40 = r(mean)
sum base_income if decile_revsal>=9 & decile_revsal!=. & sample==1
global mean_t20 = r(mean)
cap drop AC0labor_all_nm AC0labor_b40_nm AC0labor_m40_nm AC0labor_t20_nm
gen AC0labor_all_nm = AC0labor*100/$mean_all if decile_revsal!=. & sample==1
gen AC0labor_b40_nm = AC0labor*100/$mean_b40 if decile_revsal<=4 & sample==1
gen AC0labor_m40_nm = AC0labor*100/$mean_m40 if decile_revsal>=5 & decile_revsal<=8 & sample==1
gen AC0labor_t20_nm = AC0labor*100/$mean_t20 if decile_revsal>=9 & decile_revsal!=. & sample==1
//
eststo All_nm: quiet reg AC0labor_all_nm mp_shock if decile_revsal!=. & sample==1, vce(clus id)
eststo B40_nm: quiet reg AC0labor_b40_nm mp_shock if decile_revsal<=4 & sample==1, vce(clus id)
eststo M40_nm: quiet reg AC0labor_m40_nm mp_shock if decile_revsal>=5 & decile_revsal<=8 & sample==1, vce(clus id)
eststo T20_nm: quiet reg AC0labor_t20_nm mp_shock if decile_revsal>=9 & decile_revsal!=. & sample==1, vce(clus id)
esttab *_nm, nocons compress keep(mp_shock) star(** 0.05 *** 0.01)
esttab *_nm using TabA6_6.tex, b(3) t(2) br noeqlines nogaps nolines nocons compress keep(mp_shock) star(** 0.05 *** 0.01) replace

*** Permanent income on lifetime earnings up to t-1
sum base_income if decile_lt_prev!=. & sample==1 
global mean_all = r(mean)
sum base_income if decile_lt_prev<=4 & sample==1
global mean_b40 = r(mean)
sum base_income if decile_lt_prev>=5 & decile_lt_prev<=8 & sample==1
global mean_m40 = r(mean)
sum base_income if decile_lt_prev>=9 & sample==1
global mean_t20 = r(mean)
cap drop AC0labor_all_lft AC0labor_b40_lft AC0labor_m40_lft AC0labor_t20_lft
gen AC0labor_all_lft = AC0labor*100/$mean_all if decile_lt_prev!=. & sample==1
gen AC0labor_b40_lft = AC0labor*100/$mean_b40 if decile_lt_prev<=4 & sample==1
gen AC0labor_m40_lft = AC0labor*100/$mean_m40 if decile_lt_prev>=5 & decile_lt_prev<=8 & sample==1
gen AC0labor_t20_lft = AC0labor*100/$mean_t20 if decile_lt_prev>=9 & sample==1
//
eststo All_lft: quiet reg AC0labor_all_lft mp_shock if decile_lt_prev!=. & sample==1, vce(clus id)
eststo B40_lft: quiet reg AC0labor_b40_lft mp_shock if decile_lt_prev<=4 & sample==1, vce(clus id)
eststo M40_lft: quiet reg AC0labor_m40_lft mp_shock if decile_lt_prev>=5 & decile_lt_prev<=8 & sample==1, vce(clus id)
eststo T20_lft: quiet reg AC0labor_t20_lft mp_shock if decile_lt_prev>=9 & sample==1, vce(clus id)
esttab All_lft B40_lft M40_lft T20_lft, nocons compress keep(mp_shock) star(** 0.05 *** 0.01)
esttab *_lft using TabA6_7.tex, b(3) t(2) br noeqlines nogaps nolines nocons compress keep(mp_shock) star(** 0.05 *** 0.01) replace

*** Winsorized outliers
sum base_income if decile_actif!=. & sample2==1 
global mean_all = r(mean)
sum base_income if decile_actif<=4 & sample2==1
global mean_b40 = r(mean)
sum base_income if decile_actif>=5 & decile_actif<=8 & sample2==1
global mean_m40 = r(mean)
sum base_income if decile_actif>=9 & sample2==1
global mean_t20 = r(mean)
gen AC0labor_all_wo = AC0labor_win*100/$mean_all if decile_actif!=. & sample2==1
gen AC0labor_b40_wo = AC0labor_win*100/$mean_b40 if decile_actif<=4 & sample2==1
gen AC0labor_m40_wo = AC0labor_win*100/$mean_m40 if decile_actif>=5 & decile_actif<=8 & sample2==1
gen AC0labor_t20_wo = AC0labor_win*100/$mean_t20 if decile_actif>=9 & sample2==1
//
eststo All_wo: quiet reg AC0labor_all_wo mp_shock if decile_actif!=. & sample2==1, vce(clus id)
eststo B40_wo: quiet reg AC0labor_b40_wo mp_shock if decile_actif<=4 & sample2==1, vce(clus id)
eststo M40_wo: quiet reg AC0labor_m40_wo mp_shock if decile_actif>=5 & decile_actif<=8 & sample2==1, vce(clus id)
eststo T20_wo: quiet reg AC0labor_t20_wo mp_shock if decile_actif>=9 & sample2==1, vce(clus id)
esttab *_wo, nocons compress keep(mp_shock) star(** 0.05 *** 0.01)
esttab *_wo using TabA6_8.tex, b(3) t(2) br noeqlines nogaps nolines nocons compress keep(mp_shock) star(** 0.05 *** 0.01) replace

*** Without financial sector
sum base_income if decile_actif!=. & sample==1 & NAF2_new!="K"
global mean_all = r(mean)
sum base_income if decile_actif<=4 & sample==1 & NAF2_new!="K"
global mean_b40 = r(mean)
sum base_income if decile_actif>=5 & decile_actif<=8 & sample==1 & NAF2_new!="K"
global mean_m40 = r(mean)
sum base_income if decile_actif>=9 & decile_actif!=. & sample==1 & NAF2_new!="K"
global mean_t20 = r(mean)
cap drop AC0labor_all_fin AC0labor_b40_fin AC0labor_m40_fin AC0labor_t20_fin
gen AC0labor_all_fin = AC0labor*100/$mean_all if decile_actif!=. & sample==1 & NAF2_new!="K"
gen AC0labor_b40_fin = AC0labor*100/$mean_b40 if decile_actif<=4 & sample==1 & NAF2_new!="K"
gen AC0labor_m40_fin = AC0labor*100/$mean_m40 if decile_actif>=5 & decile_actif<=8 & sample==1 & NAF2_new!="K"
gen AC0labor_t20_fin = AC0labor*100/$mean_t20 if decile_actif>=9 & decile_actif!=. & sample==1 & NAF2_new!="K"
//
eststo All_fin: quiet reg AC0labor_all_fin mp_shock if decile_actif!=. & sample==1 & NAF2_new!="K", vce(clus id)
eststo B40_fin: quiet reg AC0labor_b40_fin mp_shock if decile_actif<=4 & sample==1 & NAF2_new!="K", vce(clus id)
eststo M40_fin: quiet reg AC0labor_m40_fin mp_shock if decile_actif>=5 & decile_actif<=8 & sample==1 & NAF2_new!="K", vce(clus id)
eststo T20_fin: quiet reg AC0labor_t20_fin mp_shock if decile_actif>=9 & decile_actif!=. & sample==1 & NAF2_new!="K", vce(clus id)
esttab *_fin, nocons compress keep(mp_shock) star(** 0.05 *** 0.01)
esttab *_fin using TabA6_9.tex, b(3) t(2) br noeqlines nogaps nolines nocons compress keep(mp_shock) star(** 0.05 *** 0.01) replace

*** Pre-QE (2007-2014)
sum base_income if decile_actif!=. & sample==1 & year<2015
global mean_all = r(mean)
sum base_income if decile_actif<=4 & sample==1 & year<2015
global mean_b40 = r(mean)
sum base_income if decile_actif>=5 & decile_actif<=8 & sample==1 & year<2015
global mean_m40 = r(mean)
sum base_income if decile_actif>=9 & decile_actif!=. & sample==1 & year<2015
global mean_t20 = r(mean)
cap drop AC0labor_all_qe AC0labor_b40_qe AC0labor_m40_qe AC0labor_t20_qe
gen AC0labor_all_qe = AC0labor*100/$mean_all if decile_actif!=. & sample==1 & year<2015
gen AC0labor_b40_qe = AC0labor*100/$mean_b40 if decile_actif<=4 & sample==1 & year<2015
gen AC0labor_m40_qe = AC0labor*100/$mean_m40 if decile_actif>=5 & decile_actif<=8 & sample==1 & year<2015
gen AC0labor_t20_qe = AC0labor*100/$mean_t20 if decile_actif>=9 & decile_actif!=. & sample==1 & year<2015
//
eststo All_qe: quiet reg AC0labor_all_qe mp_shock if decile_actif!=. & sample==1 & year<2015, vce(clus id)
eststo B40_qe: quiet reg AC0labor_b40_qe mp_shock if decile_actif<=4 & sample==1 & year<2015, vce(clus id)
eststo M40_qe: quiet reg AC0labor_m40_qe mp_shock if decile_actif>=5 & decile_actif<=8 & sample==1 & year<2015, vce(clus id)
eststo T20_qe: quiet reg AC0labor_t20_qe mp_shock if decile_actif>=9 & decile_actif!=. & sample==1 & year<2015, vce(clus id)
esttab *_qe, nocons compress keep(mp_shock) star(** 0.05 *** 0.01)
esttab *_qe using TabA6_10.tex, b(3) t(2) br noeqlines nogaps nolines nocons compress keep(mp_shock) star(** 0.05 *** 0.01) replace

*** Post-GFC (2011-2019)
sum base_income if decile_actif!=. & sample==1 & year>2011
global mean_all = r(mean)
sum base_income if decile_actif<=4 & sample==1 & year>2011
global mean_b40 = r(mean)
sum base_income if decile_actif>=5 & decile_actif<=8 & sample==1 & year>2011
global mean_m40 = r(mean)
sum base_income if decile_actif>=9 & decile_actif!=. & sample==1 & year>2011
global mean_t20 = r(mean)
cap drop AC0labor_all_gfc AC0labor_b40_gfc AC0labor_m40_gfc AC0labor_t20_gfc
gen AC0labor_all_gfc = AC0labor*100/$mean_all if decile_actif!=. & sample==1 & year>2011
gen AC0labor_b40_gfc = AC0labor*100/$mean_b40 if decile_actif<=4 & sample==1 & year>2011
gen AC0labor_m40_gfc = AC0labor*100/$mean_m40 if decile_actif>=5 & decile_actif<=8 & sample==1 & year>2011
gen AC0labor_t20_gfc = AC0labor*100/$mean_t20 if decile_actif>=9 & decile_actif!=. & sample==1 & year>2011
//
eststo All_gfc: quiet reg AC0labor_all_gfc mp_shock if decile_actif!=. & sample==1 & year>2011, vce(clus id)
eststo B40_gfc: quiet reg AC0labor_b40_gfc mp_shock if decile_actif<=4 & sample==1 & year>2011, vce(clus id)
eststo M40_gfc: quiet reg AC0labor_m40_gfc mp_shock if decile_actif>=5 & decile_actif<=8 & sample==1 & year>2011, vce(clus id)
eststo T20_gfc: quiet reg AC0labor_t20_gfc mp_shock if decile_actif>=9 & decile_actif!=. & sample==1 & year>2011, vce(clus id)
esttab *_gfc, nocons compress keep(mp_shock) star(** 0.05 *** 0.01)
esttab *_gfc using TabA6_11.tex, b(3) t(2) br noeqlines nogaps nolines nocons compress keep(mp_shock) star(** 0.05 *** 0.01) replace

*** Kerssenficher2019 MP shocks
cap drop mp_shock mp_shock1
egen mp_shock1 = std(k19_mp)
gen mp_shock = -1*mp_shock1
//
cap drop _est_All_mp _est_B40_mp _est_M40_mp _est_T20_mp
eststo All_mp: quiet reg AC0labor_all mp_shock if decile_actif!=. & sample==1, vce(clus id)
eststo B40_mp: quiet reg AC0labor_b40 mp_shock if decile_actif<=4 & sample==1, vce(clus id)
eststo M40_mp: quiet reg AC0labor_m40 mp_shock if decile_actif>=5 & decile_actif<=8 & sample==1, vce(clus id)
eststo T20_mp: quiet reg AC0labor_t20 mp_shock if decile_actif>=9 & decile_actif!=. & sample==1, vce(clus id)
esttab *_mp, nocons compress keep(mp_shock) star(** 0.05 *** 0.01)
esttab *_mp using TabA6_12.tex, b(3) t(2) br noeqlines nogaps nolines nocons compress keep(mp_shock) star(** 0.05 *** 0.01) replace
//
cap drop mp_shock mp_shock1
egen mp_shock1 = std(jk19_mpsign)
gen mp_shock = -1*mp_shock1

*** Weighted sum MP shocks
cap drop mp_shock 
gen mp_shock = mp_shock_w
//
eststo All_ws: quiet reg AC0labor_all mp_shock if decile_actif!=. & sample==1, vce(clus id)
eststo B40_ws: quiet reg AC0labor_b40 mp_shock if decile_actif<=4 & sample==1, vce(clus id)
eststo M40_ws: quiet reg AC0labor_m40 mp_shock if decile_actif>=5 & decile_actif<=8 & sample==1, vce(clus id)
eststo T20_ws: quiet reg AC0labor_t20 mp_shock if decile_actif>=9 & decile_actif!=. & sample==1, vce(clus id)
esttab *_ws, nocons compress keep(mp_shock) star(** 0.05 *** 0.01)
esttab *_ws using TabA6_13.tex, b(3) t(2) br noeqlines nogaps nolines nocons compress ///
keep(mp_shock) stats(N) star(** 0.05 *** 0.01) replace
//
cap drop mp_shock mp_shock1
egen mp_shock1 = std(jk19_mpsign)
gen mp_shock = -1*mp_shock1

*** Including macro controls
local controls growth unemp_d ib stress_d stockr_d oil_d
eststo All_mc: quiet reg AC0labor_all mp_shock `controls' if decile_actif!=. & sample==1, vce(clus id)
eststo B40_mc: quiet reg AC0labor_b40 mp_shock `controls' if decile_actif<=4 & sample==1, vce(clus id)
eststo M40_mc: quiet reg AC0labor_m40 mp_shock `controls' if decile_actif>=5 & decile_actif<=8 & sample==1, vce(clus id)
eststo T20_mc: quiet reg AC0labor_t20 mp_shock `controls' if decile_actif>=9 & decile_actif!=. & sample==1, vce(clus id)
esttab *_mc, nocons compress keep(mp_shock) star(** 0.05 *** 0.01)
esttab *_mc using TabA6_14.tex, b(3) t(2) br noeqlines nogaps nolines nocons compress keep(mp_shock) star(** 0.05 *** 0.01) replace

*** All controls
xtset id year
local controls i.age i.DIPLOME i.cs24 i.HX060 i.nivact_new i.occupation i.contrat fe_sector_* growth unemp_d ib stress_d stockr_d oil_d
eststo All_ac: quiet reg AC0labor_all mp_shock `controls' if decile_actif!=. & sample==1, vce(clus id)
eststo B40_ac: quiet reg AC0labor_b40 mp_shock `controls' if decile_actif<=4 & sample==1, vce(clus id)
eststo M40_ac: quiet reg AC0labor_m40 mp_shock `controls' if decile_actif>=5 & decile_actif<=8 & sample==1, vce(clus id)
eststo T20_ac: quiet reg AC0labor_t20 mp_shock `controls' if decile_actif>=9 & decile_actif!=. & sample==1, vce(clus id)
esttab *_ac, nocons compress keep(mp_shock) star(** 0.05 *** 0.01)
esttab *_ac using TabA6_15.tex, b(3) t(2) br noeqlines nogaps nolines nocons compress keep(mp_shock) star(** 0.05 *** 0.01) replace


*****************************
*** FIGURE 2 - ROBUSTNESS ***
*****************************

coefplot (All, label(Baseline) mcolor(blue) msymbol(S) msize(medium) levels(90 68) offset(-0.35) ciopts(lwidth(1.5 1.5) lcolor(blue*.3 blue*.6))) ///
(All_fe, label(FE+IdControls) mcolor(green) msymbol(S) msize(medium) levels(90 68) offset(-0.30) ciopts(lwidth(1.5 1.5) lcolor(green*.3 green*.6))) ///
(All_ub, label(W/ UnempB) mcolor(lavender) msymbol(S) msize(medium) levels(90 68) offset(-0.25) ciopts(lwidth(1.5 1.5) lcolor(lavender*.3 lavender*.6))) ///
(All_w, label(W/o SelfEmp) mcolor(pink) msymbol(S) msize(medium) levels(90 68) offset(-0.20) ciopts(lwidth(1.5 1.5) lcolor(pink*.3 pink*.6))) ///
(All_dh, label(Arc-percent) mcolor(black) msymbol(S) msize(medium) levels(90 68) offset(-0.15) ciopts(lwidth(1.5 1.5) lcolor(black*.3 black*.6))) ///
(All_nm, label(NonMissLI) mcolor(navy) msymbol(S) msize(medium) levels(90 68) offset(-0.10) ciopts(lwidth(1.5 1.5) lcolor(navy*.3 navy*.6))) ///
(All_lft, label(Lifetime Earn.) mcolor(purple) msymbol(S) msize(medium) levels(90 68) offset(-0.05) ciopts(lwidth(1.5 1.5) lcolor(purple*.3 purple*.6))) ///
(All_wo, label(Winsorized) mcolor(orange) msymbol(S) msize(medium) levels(90 68) offset(0) ciopts(lwidth(1.5 1.5) lcolor(orange*.3 orange*.6))) ///
(All_fin, label(W/o Finance) mcolor(ebblue) msymbol(S) msize(medium) levels(90 68) offset(0.05) ciopts(lwidth(1.5 1.5) lcolor(ebblue*.3 ebblue*.6))) ///
(All_qe, label(Pre-QE) mcolor(red) msymbol(S) msize(medium) levels(90 68) offset(0.10) ciopts(lwidth(1.5 1.5) lcolor(red*.3 red*.6))) ///
(All_gfc, label(Post-GFC) mcolor(brown) msymbol(S) msize(medium) levels(90 68) offset(0.15) ciopts(lwidth(1.5 1.5) lcolor(brown*.4 brown*.7))) ///
(All_mp, label(K19 MPshock) mcolor(maroon) msymbol(S) msize(medium) levels(90 68) offset(0.20) ciopts(lwidth(1.5 1.5) lcolor(maroon*.3 maroon*.6))) ///
(All_ws, label(Weighted Sum) mcolor(gold) msymbol(S) msize(medium) levels(90 68) offset(0.25) ciopts(lwidth(1.5 1.5) lcolor(gold*.3 gold*.6))) ///
(All_mc, label(MacroControls) mcolor(olive) msymbol(S) msize(medium) levels(90 68) offset(0.30) ciopts(lwidth(1.5 1.5) lcolor(olive*.3 olive*.6))) ///
(All_ac, label(AllControls) mcolor(eltgreen) msymbol(S) msize(medium) levels(90 68) offset(0.35) ciopts(lwidth(1.5 1.5) lcolor(eltgreen*.3 eltgreen*.6))) ///
|| (Bottom40, label(Baseline) mcolor(blue) msymbol(S) msize(medium) levels(90 68) offset(-0.35) ciopts(lwidth(1.5 1.5) lcolor(blue*.3 blue*.6))) ///
(B40_fe, label(FE+IdControls) mcolor(green) msymbol(S) msize(medium) levels(90 68) offset(-0.30) ciopts(lwidth(1.5 1.5) lcolor(green*.3 green*.6))) ///
(B40_ub, label(W/ UnempB) mcolor(lavender) msymbol(S) msize(medium) levels(90 68) offset(-0.25) ciopts(lwidth(1.5 1.5) lcolor(lavender*.3 lavender*.6))) ///
(B40_w, label(W/o SelfEmp) mcolor(pink) msymbol(S) msize(medium) levels(90 68) offset(-0.20) ciopts(lwidth(1.5 1.5) lcolor(pink*.3 pink*.6))) ///
(B40_dh, label(Arc-percent) mcolor(black) msymbol(S) msize(medium) levels(90 68) offset(-0.15) ciopts(lwidth(1.5 1.5) lcolor(black*.3 black*.6))) ///
(B40_nm, label(NonMissLI) mcolor(navy) msymbol(S) msize(medium) levels(90 68) offset(-0.10) ciopts(lwidth(1.5 1.5) lcolor(navy*.3 navy*.6))) ///
(B40_lft, label(Lifetime Earn.) mcolor(purple) msymbol(S) msize(medium) levels(90 68) offset(-0.05) ciopts(lwidth(1.5 1.5) lcolor(purple*.3 purple*.6))) ///
(B40_wo, label(Winsorized) mcolor(orange) msymbol(S) msize(medium) levels(90 68) offset(0) ciopts(lwidth(1.5 1.5) lcolor(orange*.3 orange*.6))) ///
(B40_fin, label(W/o Finance) mcolor(ebblue) msymbol(S) msize(medium) levels(90 68) offset(0.05) ciopts(lwidth(1.5 1.5) lcolor(ebblue*.3 ebblue*.6))) ///
(B40_qe, label(Pre-QE) mcolor(red) msymbol(S) msize(medium) levels(90 68) offset(0.10) ciopts(lwidth(1.5 1.5) lcolor(red*.3 red*.6))) ///
(B40_gfc, label(Post-GFC) mcolor(brown) msymbol(S) msize(medium) levels(90 68) offset(0.15) ciopts(lwidth(1.5 1.5) lcolor(brown*.4 brown*.7))) ///
(B40_mp, label(K19 MPshock) mcolor(maroon) msymbol(S) msize(medium) levels(90 68) offset(0.20) ciopts(lwidth(1.5 1.5) lcolor(maroon*.3 maroon*.6))) ///
(B40_ws, label(Weighted Sum) mcolor(gold) msymbol(S) msize(medium) levels(90 68) offset(0.25) ciopts(lwidth(1.5 1.5) lcolor(gold*.3 gold*.6))) ///
(B40_mc, label(MacroControls) mcolor(olive) msymbol(S) msize(medium) levels(90 68) offset(0.30) ciopts(lwidth(1.5 1.5) lcolor(olive*.3 olive*.6))) ///
(B40_ac, label(AllControls) mcolor(eltgreen) msymbol(S) msize(medium) levels(90 68) offset(0.35) ciopts(lwidth(1.5 1.5) lcolor(eltgreen*.3 eltgreen*.6))) ///
|| (Middle40, label(Baseline) mcolor(blue) msymbol(S) msize(medium) levels(90 68) offset(-0.35) ciopts(lwidth(1.5 1.5) lcolor(blue*.3 blue*.6))) ///
(M40_fe, label(FE+IdControls) mcolor(green) msymbol(S) msize(medium) levels(90 68) offset(-0.30) ciopts(lwidth(1.5 1.5) lcolor(green*.3 green*.6))) ///
(M40_ub, label(W/ UnempB) mcolor(lavender) msymbol(S) msize(medium) levels(90 68) offset(-0.25) ciopts(lwidth(1.5 1.5) lcolor(lavender*.3 lavender*.6))) ///
(M40_w, label(W/o SelfEmp) mcolor(pink) msymbol(S) msize(medium) levels(90 68) offset(-0.20) ciopts(lwidth(1.5 1.5) lcolor(pink*.3 pink*.6))) ///
(M40_dh, label(Arc-percent) mcolor(black) msymbol(S) msize(medium) levels(90 68) offset(-0.15) ciopts(lwidth(1.5 1.5) lcolor(black*.3 black*.6))) ///
(M40_nm, label(NonMissLI) mcolor(navy) msymbol(S) msize(medium) levels(90 68) offset(-0.10) ciopts(lwidth(1.5 1.5) lcolor(navy*.3 navy*.6))) ///
(M40_lft, label(Lifetime Earn.) mcolor(purple) msymbol(S) msize(medium) levels(90 68) offset(-0.05) ciopts(lwidth(1.5 1.5) lcolor(purple*.3 purple*.6))) ///
(M40_wo, label(Winsorized) mcolor(orange) msymbol(S) msize(medium) levels(90 68) offset(0) ciopts(lwidth(1.5 1.5) lcolor(orange*.3 orange*.6))) ///
(M40_fin, label(W/o Finance) mcolor(ebblue) msymbol(S) msize(medium) levels(90 68) offset(0.05) ciopts(lwidth(1.5 1.5) lcolor(ebblue*.3 ebblue*.6))) ///
(M40_qe, label(Pre-QE) mcolor(red) msymbol(S) msize(medium) levels(90 68) offset(0.10) ciopts(lwidth(1.5 1.5) lcolor(red*.3 red*.6))) ///
(M40_gfc, label(Post-GFC) mcolor(brown) msymbol(S) msize(medium) levels(90 68) offset(0.15) ciopts(lwidth(1.5 1.5) lcolor(brown*.4 brown*.7))) ///
(M40_mp, label(K19 MPshock) mcolor(maroon) msymbol(S) msize(medium) levels(90 68) offset(0.20) ciopts(lwidth(1.5 1.5) lcolor(maroon*.3 maroon*.6))) ///
(M40_ws, label(Weighted Sum) mcolor(gold) msymbol(S) msize(medium) levels(90 68) offset(0.25) ciopts(lwidth(1.5 1.5) lcolor(gold*.3 gold*.6))) ///
(M40_mc, label(MacroControls) mcolor(olive) msymbol(S) msize(medium) levels(90 68) offset(0.30) ciopts(lwidth(1.5 1.5) lcolor(olive*.3 olive*.6))) ///
(M40_ac, label(AllControls) mcolor(eltgreen) msymbol(S) msize(medium) levels(90 68) offset(0.35) ciopts(lwidth(1.5 1.5) lcolor(eltgreen*.3 eltgreen*.6))) ///
|| (Top20, label(Baseline) mcolor(blue) msymbol(S) msize(medium) levels(90 68) offset(-0.35) ciopts(lwidth(1.5 1.5) lcolor(blue*.3 blue*.6))) ///
(T20_fe, label(FE+IdControls) mcolor(green) msymbol(S) msize(medium) levels(90 68) offset(-0.30) ciopts(lwidth(1.5 1.5) lcolor(green*.3 green*.6))) ///
(T20_ub, label(W/ UnempB) mcolor(lavender) msymbol(S) msize(medium) levels(90 68) offset(-0.25) ciopts(lwidth(1.5 1.5) lcolor(lavender*.3 lavender*.6))) ///
(T20_w, label(W/o SelfEmp) mcolor(pink) msymbol(S) msize(medium) levels(90 68) offset(-0.20) ciopts(lwidth(1.5 1.5) lcolor(pink*.3 pink*.6))) ///
(T20_dh, label(Arc-percent) mcolor(black) msymbol(S) msize(medium) levels(90 68) offset(-0.15) ciopts(lwidth(1.5 1.5) lcolor(black*.3 black*.6))) ///
(T20_nm, label(NonMissLI) mcolor(navy) msymbol(S) msize(medium) levels(90 68) offset(-0.10) ciopts(lwidth(1.5 1.5) lcolor(navy*.3 navy*.6))) ///
(T20_lft, label(Lifetime Earn.) mcolor(purple) msymbol(S) msize(medium) levels(90 68) offset(-0.05) ciopts(lwidth(1.5 1.5) lcolor(purple*.3 purple*.6))) ///
(T20_wo, label(Winsorized) mcolor(orange) msymbol(S) msize(medium) levels(90 68) offset(0) ciopts(lwidth(1.5 1.5) lcolor(orange*.3 orange*.6))) ///
(T20_fin, label(W/o Finance) mcolor(ebblue) msymbol(S) msize(medium) levels(90 68) offset(0.05) ciopts(lwidth(1.5 1.5) lcolor(ebblue*.3 ebblue*.6))) ///
(T20_qe, label(Pre-QE) mcolor(red) msymbol(S) msize(medium) levels(90 68) offset(0.10) ciopts(lwidth(1.5 1.5) lcolor(red*.3 red*.6))) ///
(T20_gfc, label(Post-GFC) mcolor(brown) msymbol(S) msize(medium) levels(90 68) offset(0.15) ciopts(lwidth(1.5 1.5) lcolor(brown*.4 brown*.7))) ///
(T20_mp, label(K19 MPshock) mcolor(maroon) msymbol(S) msize(medium) levels(90 68) offset(0.20) ciopts(lwidth(1.5 1.5) lcolor(maroon*.3 maroon*.6))) ///
(T20_ws, label(Weighted Sum) mcolor(gold) msymbol(S) msize(medium) levels(90 68) offset(0.25) ciopts(lwidth(1.5 1.5) lcolor(gold*.3 gold*.6))) ///
(T20_mc, label(MacroControls) mcolor(olive) msymbol(S) msize(medium) levels(90 68) offset(0.30) ciopts(lwidth(1.5 1.5) lcolor(olive*.3 olive*.6))) ///
(T20_ac, label(AllControls) mcolor(eltgreen) msymbol(S) msize(medium) levels(90 68) offset(0.35) ciopts(lwidth(1.5 1.5) lcolor(eltgreen*.3 eltgreen*.6))), ///
drop(_cons) keep(mp_shock) bycoefs vertical yline(0) ///
ylabel(-0.5(0.5)4.5, angle(horiz) labsize(small)) yscale(titlegap(*+3)) ///
ytitle("Percent") legend(position(2) ring(0) col(3) size(small) keyg(*.5) rowg(*.2) colgap(*.2)) ///
graphregion(fcolor(white) lcolor(white)) plotregion(fcolor(white) lcolor(black)) ///
aspectratio(0.45) scale(*1.2) xsize(8) ysize(4)
graph export "Fig2_Robustness.png", width(3200) height(1600) replace
graph export "Fig2_Robustness.eps", replace


***************************
**** FIGURE 3 - Year FE ***
***************************

gen B40_group = 0 if decile_actif>=5 & decile_actif<=8 & sample==1
replace B40_group = 1 if decile_actif<=4 & sample==1
tab B40_group
gen T20_group = 0 if decile_actif>=5 & decile_actif<=8 & sample==1
replace T20_group = 1 if decile_actif>=9 & decile_actif!=. & sample==1
tab T20_group
//
gen interact = .
//
cap drop random
set seed 74125
gen random = rnormal(0,1000)
//
eststo clear
replace interact = mp_shock*B40_group
eststo B40: reghdfe AC0labor_all interact mp_shock B40_group if decile_actif!=. & sample==1, absorb(id year) vce(clus id)
replace interact = random
eststo M40: reghdfe AC0labor_all interact if decile_actif!=. & sample==1, absorb(id year) vce(clus id)
replace interact = mp_shock*T20_group
eststo T20: reghdfe AC0labor_all interact mp_shock T20_group if decile_actif!=. & sample==1, absorb(id year) vce(clus id)
esttab B40 M40 T20, nocons compress keep(interact) star(** 0.05 *** 0.01)
//
coefplot (B40, mcolor(blue) msymbol(S) msize(medlarge) levels(90 68) ciopts(lwidth(1.5 1.5) lcolor(blue*.3 blue*.6))) ///
|| (M40, mcolor(blue) msymbol(S) msize(medlarge) levels(1 1) ciopts(lwidth(1.5 1.5) lcolor(blue*.3 blue*.6))) ///
|| (T20, mcolor(blue) msymbol(S) msize(medlarge) levels(90 68) ciopts(lwidth(1.5 1.5) lcolor(blue*.3 blue*.6))), ///
keep(interact) bycoefs vertical yline(0) ///
ylabel(#5, angle(horiz) labsize(small)) yscale(titlegap(*-1)) ///
ytitle("Percent") ///
graphregion(fcolor(white) lcolor(white)) plotregion(fcolor(white) lcolor(black)) ///
aspectratio(0.9) scale(*1.2) xsize(4.5) ysize(4)
graph export "Fig3_YearFE.png", width(1800) height(1600) replace
graph export "Fig3_YearFE.eps", replace

*--------------------------------------------------------------------------*
*--------------------------------------------------------------------------*
*------------- SECTION 4: Extensive and Intensive Margins -----------------*
*--------------------------------------------------------------------------*
*--------------------------------------------------------------------------*

xtset id year

*-------------------------------------------------*
*-------------- Extensive margin -----------------*
*-------------------------------------------------*

*** TABLE A8 ***
eststo clear
eststo: quiet reg Dchomage mp_shock if decile_actif!=. & sample==1, vce(clus id)
eststo: quiet reg Dchomage mp_shock if decile_actif<=4 & sample==1, vce(clus id)
eststo: quiet reg Dchomage mp_shock if decile_actif>=5 & decile_actif<=8 & sample==1, vce(clus id)
eststo: quiet reg Dchomage mp_shock if decile_actif>=9 & decile_actif!=. & sample==1, vce(clus id)
esttab, nocons compress keep(mp_shock) star(** 0.05 *** 0.01)
esttab using TabA8a.tex, b(3) t(2) br noeqlines nogaps nolines nocons compress ///
keep(mp_shock) stats(N) star(** 0.05 *** 0.01) replace

*** Mean by group
sum chomage if decile_actif!=. & sample==1
sum chomage if decile_actif<=4 & sample==1
sum chomage if decile_actif>=5 & decile_actif<=8 & sample==1
sum chomage if decile_actif>=9 & decile_actif!=. & sample==1

*** Graphical representation
eststo clear
eststo All: quiet reg Dchomage mp_shock if decile_actif!=. & sample==1, vce(clus id)
eststo Bottom40: quiet reg Dchomage mp_shock if decile_actif<=4 & sample==1, vce(clus id)
eststo Middle40: quiet reg Dchomage mp_shock if decile_actif>=5 & decile_actif<=8 & sample==1, vce(clus id)
eststo Top20: quiet reg Dchomage mp_shock if decile_actif>=9 & decile_actif!=. & sample==1, vce(clus id)
esttab All Bottom40 Middle40 Top20, nocons compress keep(mp_shock) star(** 0.05 *** 0.01)

*** FIGURE 4 ***
coefplot All || Bottom40 || Middle40 || Top20, ///
drop(_cons) bycoefs vertical yline(0) ///
levels(90 68) ciopts(lwidth(2 2) lcolor(blue*.3 blue*.6)) ///
mcolor(blue) msymbol(S) msize(medlarge) ///
title("Extensive margin - Prob(Unemp)", size(medium) color(black)) ///
ylabel(#5, angle(horiz) labsize(small)) yscale(titlegap(*0)) ///
ytitle("Percentage points") ///
graphregion(fcolor(white) lcolor(white)) plotregion(fcolor(white) lcolor(black)) ///
aspectratio(0.9) scale(*1.2) xsize(4.5) ysize(4)
graph export "Fig4_Extensive.png", width(1800) height(1600) replace
graph export "Fig4_Extensive.eps", replace

*** TABLE 2 - Transitions from E to U ***
gen EU = .
replace EU = 0 if L1.situa_new==4 & L1.id==id
replace EU = 0 if situa_new==4 & L1.id==id
replace EU = 0 if L1.situa_new==1 & situa_new==1 & L1.id==id
replace EU = 100 if L1.situa_new==1 & situa_new==4 & L1.id==id
//
eststo clear
eststo: quiet reg EU mp_shock if decile_actif!=. & sample==1, vce(clus id)
eststo: quiet reg EU mp_shock if decile_actif<=4 & sample==1, vce(clus id)
eststo: quiet reg EU mp_shock if decile_actif>=5 & decile_actif<=8 & sample==1, vce(clus id)
eststo: quiet reg EU mp_shock if decile_actif>=9 & decile_actif!=. & sample==1, vce(clus id)
esttab, nocons compress keep(mp_shock) star(** 0.05 *** 0.01)
esttab using Tab2a.tex, b(3) t(2) br noeqlines nogaps nolines nocons compress ///
keep(mp_shock) star(** 0.05 *** 0.01) replace

*** TABLE 2 - Transitions from U to E ***
gen UE = .
replace UE = 0 if L1.situa_new==1 & L1.id==id
replace UE = 0 if situa_new==1 & L1.id==id
replace UE = 0 if L1.situa_new==4 & situa_new==4 & L1.id==id
replace UE = 100 if L1.situa_new==4 & situa_new==1 & L1.id==id
//
eststo clear
eststo: quiet reg UE mp_shock if decile_actif!=. & sample==1, vce(clus id)
eststo: quiet reg UE mp_shock if decile_actif<=4 & sample==1, vce(clus id)
eststo: quiet reg UE mp_shock if decile_actif>=5 & decile_actif<=8 & sample==1, vce(clus id)
eststo: quiet reg UE mp_shock if decile_actif>=9 & decile_actif!=. & sample==1, vce(clus id)
esttab, nocons compress keep(mp_shock) star(** 0.05 *** 0.01)
esttab using Tab2b.tex, b(3) t(2) br noeqlines nogaps nolines nocons compress ///
keep(mp_shock) star(** 0.05 *** 0.01) replace

*** TABLE 2 - Nbmois_cho (if not always unemployed) ***
eststo clear
eststo: quiet reg nbmois_cho mp_shock if decile_actif!=. & sample==1 & nbmois_cho!=12, vce(clus id)
eststo: quiet reg nbmois_cho mp_shock if decile_actif<=4 & sample==1 & nbmois_cho!=12, vce(clus id)
eststo: quiet reg nbmois_cho mp_shock if decile_actif>=5 & decile_actif<=8 & sample==1 & nbmois_cho!=12, vce(clus id)
eststo: quiet reg nbmois_cho mp_shock if decile_actif>=9 & decile_actif!=. & sample==1 & nbmois_cho!=12, vce(clus id)
esttab, nocons compress keep(mp_shock) star(** 0.05 *** 0.01)
esttab using Tab2c.tex, b(3) t(2) br noeqlines nogaps nolines nocons compress ///
keep(mp_shock) star(** 0.05 *** 0.01) replace


*-------------------------------------------------*
*-------------- Intensive margin -----------------*
*-------------------------------------------------*

*** Effet sur salaires if employed==1
eststo clear
eststo: quiet reg AC0labor mp_shock if decile_actif!=. & sample==1 & employed==1, vce(clus id)
eststo: quiet reg AC0labor mp_shock if decile_actif<=4 & sample==1 & employed==1, vce(clus id)
eststo: quiet reg AC0labor mp_shock if decile_actif>=5 & decile_actif<=8 & sample==1 & employed==1, vce(clus id)
eststo: quiet reg AC0labor mp_shock if decile_actif>=9 & decile_actif!=. & sample==1 & employed==1, vce(clus id)
esttab, nocons compress keep(mp_shock) star(** 0.05 *** 0.01)

*** In % of average income
sum base_income if decile_actif!=. & sample==1 & employed==1 	
global mean_all = r(mean)				
sum base_income if decile_actif<=4 & sample==1 & employed==1	
global mean_b40 = r(mean)			
sum base_income if decile_actif>=5 & decile_actif<=8 & sample==1 & employed==1 	
global mean_m40 = r(mean)
sum base_income if decile_actif>=9 & decile_actif!=. & sample==1 & employed==1 
global mean_t20 = r(mean)
cap drop intensive_*
gen intensive_all = AC0labor*100/$mean_all if decile_actif!=. & sample==1 & employed==1
gen intensive_b40 = AC0labor*100/$mean_b40 if decile_actif<=4 & sample==1 & employed==1
gen intensive_m40 = AC0labor*100/$mean_m40 if decile_actif>=5 & decile_actif<=8 & sample==1 & employed==1
gen intensive_t20 = AC0labor*100/$mean_t20 if decile_actif>=9 & decile_actif!=. & sample==1 & employed==1

*** TABLE A8 ***
eststo clear
eststo All: quiet reg intensive_all mp_shock if decile_actif!=. & sample==1 & employed==1, vce(clus id)
eststo Bottom40: quiet reg intensive_b40 mp_shock if decile_actif<=4 & sample==1 & employed==1, vce(clus id)
eststo Middle40: quiet reg intensive_m40 mp_shock if decile_actif>=5 & decile_actif<=8 & sample==1 & employed==1, vce(clus id)
eststo Top20: quiet reg intensive_t20 mp_shock if decile_actif>=9 & decile_actif!=. & sample==1 & employed==1, vce(clus id)
esttab All Bottom40 Middle40 Top20, nocons compress keep(mp_shock) star(** 0.05 *** 0.01)
esttab using TabA8b.tex, b(3) t(2) br noeqlines nogaps nolines nocons compress ///
keep(mp_shock) star(** 0.05 *** 0.01) replace

*** FIGURE 4 ***
coefplot All || Bottom40 || Middle40 || Top20, ///
drop(_cons actder) bycoefs vertical yline(0) ///
levels(90 68) ciopts(lwidth(2 2) lcolor(blue*.3 blue*.6)) ///
mcolor(blue) msymbol(S) msize(medlarge) ///
title("Intensive margin - {&Delta}Y if Employed", size(medium) color(black)) ///
ylabel(#5, angle(horiz) labsize(small)) yscale(titlegap(*-1)) ///
ytitle("Percent") ///
graphregion(fcolor(white) lcolor(white)) plotregion(fcolor(white) lcolor(black)) ///
aspectratio(0.9) scale(*1.2) xsize(4.5) ysize(4)
graph export "Fig4_Intensive.png", width(1800) height(1600) replace
graph export "Fig4_Intensive.eps", replace


*** TABLE 3 - Controlling for employer change ***
eststo clear
eststo: quiet reg intensive_all mp_shock actder if decile_actif!=. & sample==1 & employed==1, vce(clus id)
eststo: quiet reg intensive_b40 mp_shock actder if decile_actif<=4 & sample==1 & employed==1, vce(clus id)
eststo: quiet reg intensive_m40 mp_shock actder if decile_actif>=5 & decile_actif<=8 & sample==1 & employed==1, vce(clus id)
eststo: quiet reg intensive_t20 mp_shock actder if decile_actif>=9 & decile_actif!=. & sample==1 & employed==1, vce(clus id)
esttab, nocons compress keep(mp_shock) star(** 0.05 *** 0.01)
esttab using Tab3a.tex, b(3) t(2) br noeqlines nogaps nolines nocons compress ///
keep(mp_shock) star(** 0.05 *** 0.01) replace

*** TABLE 3 - Controlling for number of jobs ***
eststo clear
eststo: quiet reg intensive_all mp_shock actder nbemp if decile_actif!=. & sample==1 & employed==1, vce(clus id)
eststo: quiet reg intensive_b40 mp_shock actder nbemp if decile_actif<=4 & sample==1 & employed==1, vce(clus id)
eststo: quiet reg intensive_m40 mp_shock actder nbemp if decile_actif>=5 & decile_actif<=8 & sample==1 & employed==1, vce(clus id)
eststo: quiet reg intensive_t20 mp_shock actder nbemp if decile_actif>=9 & decile_actif!=. & sample==1 & employed==1, vce(clus id)
esttab, nocons compress keep(mp_shock) star(** 0.05 *** 0.01) 
esttab using Tab3b.tex, b(3) t(2) br noeqlines nogaps nolines nocons compress ///
keep(mp_shock) star(** 0.05 *** 0.01) replace

*** TABLE 3 - Controlling for nb of months at full time ***
xtset id year
gen Dnbmois_ft = F.pl073 - pl073 if F.id==id
//
eststo clear
eststo: quiet reg intensive_all mp_shock actder nbemp Dnbmois_ft pl073 if decile_actif!=. & sample==1 & employed==1, vce(clus id)
eststo: quiet reg intensive_b40 mp_shock actder nbemp Dnbmois_ft pl073 if decile_actif<=4 & sample==1 & employed==1, vce(clus id)
eststo: quiet reg intensive_m40 mp_shock actder nbemp Dnbmois_ft pl073 if decile_actif>=5 & decile_actif<=8 & sample==1 & employed==1, vce(clus id)
eststo: quiet reg intensive_t20 mp_shock actder nbemp Dnbmois_ft pl073 if decile_actif>=9 & decile_actif!=. & sample==1 & employed==1, vce(clus id)
esttab, nocons compress keep(mp_shock) star(** 0.05 *** 0.01) 
esttab using Tab3c.tex, b(3) t(2) br noeqlines nogaps nolines nocons compress ///
keep(mp_shock) star(** 0.05 *** 0.01) replace


*** FOOTNOTE: Without top1% or 2% ***
xtile ptile = base_income if situa_actif==1, nq(100)
tab ptile
tab ptile decile_actif if ptile==100
//
sum base_income if decile_actif!=. & sample==1 & employed==1 	
global mean_all = r(mean)				
sum base_income if decile_actif<=4 & sample==1 & employed==1	
global mean_b40 = r(mean)			
sum base_income if decile_actif>=5 & decile_actif<=8 & sample==1 & employed==1 	
global mean_m40 = r(mean)
sum base_income if decile_actif>=9 & decile_actif!=. & sample==1 & employed==1 & ptile<98
global mean_t20_98 = r(mean)
sum base_income if decile_actif>=9 & decile_actif!=. & sample==1 & employed==1 & ptile<99
global mean_t20_99 = r(mean)
cap drop intensive_*
gen intensive_all = AC0labor*100/$mean_all if decile_actif!=. & sample==1 & employed==1
gen intensive_b40 = AC0labor*100/$mean_b40 if decile_actif<=4 & sample==1 & employed==1
gen intensive_m40 = AC0labor*100/$mean_m40 if decile_actif>=5 & decile_actif<=8 & sample==1 & employed==1
gen intensive_t20_98 = AC0labor*100/$mean_t20_98 if decile_actif>=9 & decile_actif!=. & sample==1 & employed==1 & ptile<98
gen intensive_t20_99 = AC0labor*100/$mean_t20_99 if decile_actif>=9 & decile_actif!=. & sample==1 & employed==1 & ptile<99
//
eststo clear
eststo: quiet reg intensive_all mp_shock if decile_actif!=. & sample==1 & employed==1 & ptile<99, vce(clus id)
eststo: quiet reg intensive_b40 mp_shock if decile_actif<=4 & sample==1 & employed==1, vce(clus id)
eststo: quiet reg intensive_m40 mp_shock if decile_actif>=5 & decile_actif<=8 & sample==1 & employed==1, vce(clus id)
eststo: quiet reg intensive_t20_98 mp_shock if decile_actif>=9 & decile_actif!=. & sample==1 & employed==1 & ptile<98, vce(clus id)
eststo: quiet reg intensive_t20_99 mp_shock if decile_actif>=9 & decile_actif!=. & sample==1 & employed==1 & ptile<99, vce(clus id)
esttab, nocons compress keep(mp_shock) star(** 0.05 *** 0.01) 


*--------------------------------------------------------------------------*
*--------------------------------------------------------------------------*
*------------------ SECTION 5: SECTORAL HETEROGENEITY ---------------------*
*--------------------------------------------------------------------------*
*--------------------------------------------------------------------------*

gen self = 1 if PY050N>0 & PY050N!=.


******************************
*** TABLE A9: NAF2 sectors ***
******************************

tab NAF2_new if decile_actif!=. & sample==1 & NAF2_new!="MISS"


*-----------------------------------------------------*
*-------- TABLE 4 - Heterogeneity - Sector -----------*
*-----------------------------------------------------*

*** OVERALL (in % of average income)
sum base_income if decile_actif!=. & sample==1
global mean_all = r(mean)	
sum base_income if decile_actif!=. & sample==1 & NAF2_new=="C" & changing_sector==0	
global mean_1 = r(mean)	
sum base_income if decile_actif!=. & sample==1 & NAF2_new=="F" & changing_sector==0	
global mean_2 = r(mean)
sum base_income if decile_actif!=. & sample==1 & NAF2_new=="K" & changing_sector==0	
global mean_5 = r(mean)					
//
cap drop intensive_*
gen intensive_all = AC0labor*100/$mean_all if decile_actif!=. & sample==1
gen intensive_1 = AC0labor*100/$mean_1 if decile_actif!=. & sample==1 & changing_sector==0
gen intensive_2 = AC0labor*100/$mean_2 if decile_actif!=. & sample==1 & changing_sector==0
gen intensive_5 = AC0labor*100/$mean_5 if decile_actif!=. & sample==1 & changing_sector==0
//
eststo clear
eststo: quiet reg intensive_all mp_shock if decile_actif!=. & sample==1, vce(clus id) 
eststo: quiet reg intensive_1 mp_shock if decile_actif!=. & sample==1 & changing_sector==0 & NAF2_new=="C", vce(clus id)
eststo: quiet reg intensive_2 mp_shock if decile_actif!=. & sample==1 & changing_sector==0 & NAF2_new=="F", vce(clus id)
eststo: quiet reg intensive_5 mp_shock if decile_actif!=. & sample==1 & changing_sector==0 & NAF2_new=="K", vce(clus id)
esttab, nocons compress keep(mp_shock) star(** 0.05 *** 0.01) ///
mtitle("All" "IndManuf" "Construc" "FinAssu")
esttab using Tab4a.tex, b(3) t(2) br noeqlines nogaps nolines nocons compress ///
mtitle("All" "IndManuf" "Construc" "FinAssu") ///
keep(mp_shock) stats(N) star(** 0.05 *** 0.01) replace


*** EXTENSIVE - Dchomage
eststo clear
eststo: quiet reg Dchomage mp_shock if decile_actif!=. & sample==1, vce(clus id) 
eststo: quiet reg Dchomage mp_shock if decile_actif!=. & sample==1 & changing_sector==0 & NAF2_new=="C", vce(clus id)
eststo: quiet reg Dchomage mp_shock if decile_actif!=. & sample==1 & changing_sector==0 & NAF2_new=="F", vce(clus id)
eststo: quiet reg Dchomage mp_shock if decile_actif!=. & sample==1 & changing_sector==0 & NAF2_new=="K", vce(clus id)
esttab, nocons compress keep(mp_shock) star(** 0.05 *** 0.01) ///
mtitle("All" "IndManuf" "Construc" "FinAssu")
esttab using Tab4b.tex, b(3) t(2) br noeqlines nogaps nolines nocons compress ///
mtitle("All" "IndManuf" "Construc" "FinAssu") ///
keep(mp_shock) stats(N) star(** 0.05 *** 0.01) replace


*** INTENSIVE - Effet sur salaires if employed==1
*** (in % of average income)
sum base_income if decile_actif!=. & sample==1 & employed==1 	
global mean_all = r(mean)	
sum base_income if decile_actif!=. & sample==1 & changing_sector==0 & employed==1 & NAF2_new=="C"	
global mean_1 = r(mean)	
sum base_income if decile_actif!=. & sample==1 & changing_sector==0 & employed==1 & NAF2_new=="F"	
global mean_2 = r(mean)					
sum base_income if decile_actif!=. & sample==1 & changing_sector==0 & employed==1 & NAF2_new=="K"	
global mean_5 = r(mean)							
//
cap drop intensive_*
gen intensive_all = AC0labor*100/$mean_all if decile_actif!=. & sample==1 & employed==1
gen intensive_1 = AC0labor*100/$mean_1 if decile_actif!=. & sample==1 & changing_sector==0 & employed==1
gen intensive_2 = AC0labor*100/$mean_2 if decile_actif!=. & sample==1 & changing_sector==0 & employed==1
gen intensive_5 = AC0labor*100/$mean_5 if decile_actif!=. & sample==1 & changing_sector==0 & employed==1
//
eststo clear
eststo: quiet reg intensive_all mp_shock if decile_actif!=. & sample==1 & employed==1, vce(clus id) 
eststo: quiet reg intensive_1 mp_shock if decile_actif!=. & sample==1 & changing_sector==0 & employed==1 & NAF2_new=="C", vce(clus id)
eststo: quiet reg intensive_2 mp_shock if decile_actif!=. & sample==1 & changing_sector==0 & employed==1 & NAF2_new=="F", vce(clus id)
eststo: quiet reg intensive_5 mp_shock if decile_actif!=. & sample==1 & changing_sector==0 & employed==1 & NAF2_new=="K", vce(clus id)
esttab, nocons compress keep(mp_shock) star(** 0.05 *** 0.01) ///
mtitle("Baseline-All" "IndManuf" "Construc" "FinAssu")
esttab using Tab4c.tex, b(3) t(2) br noeqlines nogaps nolines nocons compress ///
mtitle("Baseline-All" "IndManuf" "Construc" "FinAssu") ///
keep(mp_shock) stats(N) star(** 0.05 *** 0.01) replace


***********************************
*** TABLE A10: OTHER 15 sectors ***
***********************************

*** Overall 
sum base_income if decile_actif!=. & sample==1 & changing_sector==0 & NAF2_new=="A"	
global mean_1 = r(mean)	
sum base_income if decile_actif!=. & sample==1 & changing_sector==0 & NAF2_new=="B"	
global mean_2 = r(mean)			
sum base_income if decile_actif!=. & sample==1 & changing_sector==0 & NAF2_new=="D"	
global mean_3 = r(mean)
sum base_income if decile_actif!=. & sample==1 & changing_sector==0 & NAF2_new=="E"	
global mean_4 = r(mean)			
sum base_income if decile_actif!=. & sample==1 & changing_sector==0 & NAF2_new=="G"	
global mean_5 = r(mean)
sum base_income if decile_actif!=. & sample==1 & NAF2_new=="H" & changing_sector==0
global mean_H = r(mean)
sum base_income if decile_actif!=. & sample==1 & NAF2_new=="I" & changing_sector==0	
global mean_I = r(mean)
sum base_income if decile_actif!=. & sample==1 & changing_sector==0 & NAF2_new=="J"	
global mean_6 = r(mean)
sum base_income if decile_actif!=. & sample==1 & changing_sector==0 & NAF2_new=="L"	
global mean_7 = r(mean)
sum base_income if decile_actif!=. & sample==1 & changing_sector==0 & NAF2_new=="M"	
global mean_8 = r(mean)
sum base_income if decile_actif!=. & sample==1 & NAF2_new=="N" & changing_sector==0	
global mean_N = r(mean)
sum base_income if decile_actif!=. & sample==1 & changing_sector==0 & NAF2_new=="O"	
global mean_9 = r(mean)
sum base_income if decile_actif!=. & sample==1 & changing_sector==0 & NAF2_new=="P"	
global mean_10 = r(mean)
sum base_income if decile_actif!=. & sample==1 & changing_sector==0 & NAF2_new=="Q"	
global mean_11 = r(mean)
sum base_income if decile_actif!=. & sample==1 & changing_sector==0 & NAF2_new=="R"	
global mean_12 = r(mean)	
//
cap drop intensive_*
gen intensive_1 = AC0labor*100/$mean_1 if decile_actif!=. & sample==1 & changing_sector==0
gen intensive_2 = AC0labor*100/$mean_2 if decile_actif!=. & sample==1 & changing_sector==0
gen intensive_3 = AC0labor*100/$mean_3 if decile_actif!=. & sample==1 & changing_sector==0
gen intensive_4 = AC0labor*100/$mean_4 if decile_actif!=. & sample==1 & changing_sector==0
gen intensive_5 = AC0labor*100/$mean_5 if decile_actif!=. & sample==1 & changing_sector==0
gen intensive_6 = AC0labor*100/$mean_6 if decile_actif!=. & sample==1 & changing_sector==0
gen intensive_7 = AC0labor*100/$mean_7 if decile_actif!=. & sample==1 & changing_sector==0
gen intensive_8 = AC0labor*100/$mean_8 if decile_actif!=. & sample==1 & changing_sector==0
gen intensive_9 = AC0labor*100/$mean_9 if decile_actif!=. & sample==1 & changing_sector==0
gen intensive_10 = AC0labor*100/$mean_10 if decile_actif!=. & sample==1 & changing_sector==0
gen intensive_11 = AC0labor*100/$mean_11 if decile_actif!=. & sample==1 & changing_sector==0
gen intensive_12 = AC0labor*100/$mean_12 if decile_actif!=. & sample==1 & changing_sector==0
gen intensive_H = AC0labor*100/$mean_H if decile_actif!=. & sample==1 & changing_sector==0
gen intensive_I = AC0labor*100/$mean_I if decile_actif!=. & sample==1 & changing_sector==0
gen intensive_N = AC0labor*100/$mean_N if decile_actif!=. & sample==1 & changing_sector==0	
//
eststo clear
eststo: quiet reg intensive_1 mp_shock if decile_actif!=. & sample==1 & changing_sector==0 & NAF2_new=="A", vce(clus id)
eststo: quiet reg intensive_2 mp_shock if decile_actif!=. & sample==1 & changing_sector==0 & NAF2_new=="B", vce(clus id)
eststo: quiet reg intensive_3 mp_shock if decile_actif!=. & sample==1 & changing_sector==0 & NAF2_new=="D", vce(clus id)
eststo: quiet reg intensive_4 mp_shock if decile_actif!=. & sample==1 & changing_sector==0 & NAF2_new=="E", vce(clus id)
eststo: quiet reg intensive_5 mp_shock if decile_actif!=. & sample==1 & changing_sector==0 & NAF2_new=="G", vce(clus id)
eststo: quiet reg intensive_H mp_shock if decile_actif!=. & sample==1 & changing_sector==0 & NAF2_new=="H", vce(clus id)
eststo: quiet reg intensive_I mp_shock if decile_actif!=. & sample==1 & changing_sector==0 & NAF2_new=="I", vce(clus id)
eststo: quiet reg intensive_6 mp_shock if decile_actif!=. & sample==1 & changing_sector==0 & NAF2_new=="J", vce(clus id)
eststo: quiet reg intensive_7 mp_shock if decile_actif!=. & sample==1 & changing_sector==0 & NAF2_new=="L", vce(clus id)
eststo: quiet reg intensive_8 mp_shock if decile_actif!=. & sample==1 & changing_sector==0 & NAF2_new=="M", vce(clus id)
eststo: quiet reg intensive_N mp_shock if decile_actif!=. & sample==1 & changing_sector==0 & NAF2_new=="N", vce(clus id)
eststo: quiet reg intensive_9 mp_shock if decile_actif!=. & sample==1 & changing_sector==0 & NAF2_new=="O", vce(clus id)
eststo: quiet reg intensive_10 mp_shock if decile_actif!=. & sample==1 & changing_sector==0 & NAF2_new=="P", vce(clus id)
eststo: quiet reg intensive_11 mp_shock if decile_actif!=. & sample==1 & changing_sector==0 & NAF2_new=="Q", vce(clus id)
eststo: quiet reg intensive_12 mp_shock if decile_actif!=. & sample==1 & changing_sector==0 & NAF2_new=="R", vce(clus id)
esttab, nocons compress keep(mp_shock) star(** 0.05 *** 0.01) ///
mtitle("A" "B" "D" "E" "G" "H" "I" "J" "L" "M" "N" "O" "P" "Q" "R")
esttab using TabA10a.tex, b(3) t(2) br noeqlines nogaps nolines nocons compress ///
mtitle("A" "B" "D" "E" "G" "H" "I" "J" "L" "M" "N" "O" "P" "Q" "R") ///
keep(mp_shock) stats(N) star(** 0.05 *** 0.01) replace


*** Extensive
eststo clear
eststo: quiet reg Dchomage mp_shock if decile_actif!=. & sample==1 & changing_sector==0 & NAF2_new=="A", vce(clus id)
eststo: quiet reg Dchomage mp_shock if decile_actif!=. & sample==1 & changing_sector==0 & NAF2_new=="B", vce(clus id)
eststo: quiet reg Dchomage mp_shock if decile_actif!=. & sample==1 & changing_sector==0 & NAF2_new=="D", vce(clus id)
eststo: quiet reg Dchomage mp_shock if decile_actif!=. & sample==1 & changing_sector==0 & NAF2_new=="E", vce(clus id)
eststo: quiet reg Dchomage mp_shock if decile_actif!=. & sample==1 & changing_sector==0 & NAF2_new=="G", vce(clus id)
eststo: quiet reg Dchomage mp_shock if decile_actif!=. & sample==1 & changing_sector==0 & NAF2_new=="H", vce(clus id)
eststo: quiet reg Dchomage mp_shock if decile_actif!=. & sample==1 & changing_sector==0 & NAF2_new=="I", vce(clus id)
eststo: quiet reg Dchomage mp_shock if decile_actif!=. & sample==1 & changing_sector==0 & NAF2_new=="J", vce(clus id)
eststo: quiet reg Dchomage mp_shock if decile_actif!=. & sample==1 & changing_sector==0 & NAF2_new=="L", vce(clus id)
eststo: quiet reg Dchomage mp_shock if decile_actif!=. & sample==1 & changing_sector==0 & NAF2_new=="M", vce(clus id)
eststo: quiet reg Dchomage mp_shock if decile_actif!=. & sample==1 & changing_sector==0 & NAF2_new=="N", vce(clus id)
eststo: quiet reg Dchomage mp_shock if decile_actif!=. & sample==1 & changing_sector==0 & NAF2_new=="O", vce(clus id)
eststo: quiet reg Dchomage mp_shock if decile_actif!=. & sample==1 & changing_sector==0 & NAF2_new=="P", vce(clus id)
eststo: quiet reg Dchomage mp_shock if decile_actif!=. & sample==1 & changing_sector==0 & NAF2_new=="Q", vce(clus id)
eststo: quiet reg Dchomage mp_shock if decile_actif!=. & sample==1 & changing_sector==0 & NAF2_new=="R", vce(clus id)
esttab, nocons compress keep(mp_shock) star(** 0.05 *** 0.01) ///
mtitle("A" "B" "D" "E" "G" "H" "I" "J" "L" "M" "N" "O" "P" "Q" "R")
esttab using TabA10b.tex, b(3) t(2) br noeqlines nogaps nolines nocons compress ///
mtitle("A" "B" "D" "E" "G" "H" "I" "J" "L" "M" "N" "O" "P" "Q" "R") ///
keep(mp_shock) stats(N) star(** 0.05 *** 0.01) replace


*** Intensive 
sum base_income if decile_actif!=. & sample==1 & changing_sector==0 & employed==1 & NAF2_new=="A"	
global mean_1 = r(mean)	
sum base_income if decile_actif!=. & sample==1 & changing_sector==0 & employed==1 & NAF2_new=="B"	
global mean_2 = r(mean)			
sum base_income if decile_actif!=. & sample==1 & changing_sector==0 & employed==1 & NAF2_new=="D"	
global mean_3 = r(mean)
sum base_income if decile_actif!=. & sample==1 & changing_sector==0 & employed==1 & NAF2_new=="E"	
global mean_4 = r(mean)			
sum base_income if decile_actif!=. & sample==1 & changing_sector==0 & employed==1 & NAF2_new=="G"	
global mean_5 = r(mean)		
sum base_income if decile_actif!=. & sample==1 & changing_sector==0 & employed==1 & NAF2_new=="J"	
global mean_6 = r(mean)
sum base_income if decile_actif!=. & sample==1 & changing_sector==0 & employed==1 & NAF2_new=="L"	
global mean_7 = r(mean)
sum base_income if decile_actif!=. & sample==1 & changing_sector==0 & employed==1 & NAF2_new=="M"	
global mean_8 = r(mean)
sum base_income if decile_actif!=. & sample==1 & changing_sector==0 & employed==1 & NAF2_new=="O"	
global mean_9 = r(mean)
sum base_income if decile_actif!=. & sample==1 & changing_sector==0 & employed==1 & NAF2_new=="P"	
global mean_10 = r(mean)
sum base_income if decile_actif!=. & sample==1 & changing_sector==0 & employed==1 & NAF2_new=="Q"	
global mean_11 = r(mean)
sum base_income if decile_actif!=. & sample==1 & changing_sector==0 & employed==1 & NAF2_new=="R"	
global mean_12 = r(mean)
sum base_income if decile_actif!=. & sample==1 & changing_sector==0 & employed==1 & NAF2_new=="H"
global mean_H = r(mean)
sum base_income if decile_actif!=. & sample==1 & changing_sector==0 & employed==1 & NAF2_new=="I"	
global mean_I = r(mean)	
sum base_income if decile_actif!=. & sample==1 & changing_sector==0 & employed==1 & NAF2_new=="N"	
global mean_N = r(mean)
//
cap drop intensive_*
gen intensive_1 = AC0labor*100/$mean_1 if decile_actif!=. & sample==1 & changing_sector==0 & employed==1
gen intensive_2 = AC0labor*100/$mean_2 if decile_actif!=. & sample==1 & changing_sector==0 & employed==1
gen intensive_3 = AC0labor*100/$mean_3 if decile_actif!=. & sample==1 & changing_sector==0 & employed==1
gen intensive_4 = AC0labor*100/$mean_4 if decile_actif!=. & sample==1 & changing_sector==0 & employed==1
gen intensive_5 = AC0labor*100/$mean_5 if decile_actif!=. & sample==1 & changing_sector==0 & employed==1
gen intensive_6 = AC0labor*100/$mean_6 if decile_actif!=. & sample==1 & changing_sector==0 & employed==1
gen intensive_7 = AC0labor*100/$mean_7 if decile_actif!=. & sample==1 & changing_sector==0 & employed==1
gen intensive_8 = AC0labor*100/$mean_8 if decile_actif!=. & sample==1 & changing_sector==0 & employed==1
gen intensive_9 = AC0labor*100/$mean_9 if decile_actif!=. & sample==1 & changing_sector==0 & employed==1
gen intensive_10 = AC0labor*100/$mean_10 if decile_actif!=. & sample==1 & changing_sector==0 & employed==1
gen intensive_11 = AC0labor*100/$mean_11 if decile_actif!=. & sample==1 & changing_sector==0 & employed==1
gen intensive_12 = AC0labor*100/$mean_12 if decile_actif!=. & sample==1 & changing_sector==0 & employed==1
gen intensive_H = AC0labor*100/$mean_H if decile_actif!=. & sample==1 & changing_sector==0 & employed==1
gen intensive_I = AC0labor*100/$mean_I if decile_actif!=. & sample==1 & changing_sector==0 & employed==1
gen intensive_N = AC0labor*100/$mean_N if decile_actif!=. & sample==1 & changing_sector==0 & employed==1
//
eststo clear
eststo: quiet reg intensive_1 mp_shock if decile_actif!=. & sample==1 & changing_sector==0 & employed==1 & NAF2_new=="A", vce(clus id)
eststo: quiet reg intensive_2 mp_shock if decile_actif!=. & sample==1 & changing_sector==0 & employed==1 & NAF2_new=="B", vce(clus id)
eststo: quiet reg intensive_3 mp_shock if decile_actif!=. & sample==1 & changing_sector==0 & employed==1 & NAF2_new=="D", vce(clus id)
eststo: quiet reg intensive_4 mp_shock if decile_actif!=. & sample==1 & changing_sector==0 & employed==1 & NAF2_new=="E", vce(clus id)
eststo: quiet reg intensive_5 mp_shock if decile_actif!=. & sample==1 & changing_sector==0 & employed==1 & NAF2_new=="G", vce(clus id)
eststo: quiet reg intensive_H mp_shock if decile_actif!=. & sample==1 & changing_sector==0 & employed==1 & NAF2_new=="H", vce(clus id)
eststo: quiet reg intensive_I mp_shock if decile_actif!=. & sample==1 & changing_sector==0 & employed==1 & NAF2_new=="I", vce(clus id)
eststo: quiet reg intensive_6 mp_shock if decile_actif!=. & sample==1 & changing_sector==0 & employed==1 & NAF2_new=="J", vce(clus id)
eststo: quiet reg intensive_7 mp_shock if decile_actif!=. & sample==1 & changing_sector==0 & employed==1 & NAF2_new=="L", vce(clus id)
eststo: quiet reg intensive_8 mp_shock if decile_actif!=. & sample==1 & changing_sector==0 & employed==1 & NAF2_new=="M", vce(clus id)
eststo: quiet reg intensive_N mp_shock if decile_actif!=. & sample==1 & changing_sector==0 & employed==1 & NAF2_new=="N", vce(clus id)
eststo: quiet reg intensive_9 mp_shock if decile_actif!=. & sample==1 & changing_sector==0 & employed==1 & NAF2_new=="O", vce(clus id)
eststo: quiet reg intensive_10 mp_shock if decile_actif!=. & sample==1 & changing_sector==0 & employed==1 & NAF2_new=="P", vce(clus id)
eststo: quiet reg intensive_11 mp_shock if decile_actif!=. & sample==1 & changing_sector==0 & employed==1 & NAF2_new=="Q", vce(clus id)
eststo: quiet reg intensive_12 mp_shock if decile_actif!=. & sample==1 & changing_sector==0 & employed==1 & NAF2_new=="R", vce(clus id)
esttab, nocons compress keep(mp_shock) star(** 0.05 *** 0.01) ///
mtitle("A" "B" "D" "E" "G" "H" "I" "J" "L" "M" "N" "O" "P" "Q" "R")
esttab using TabA10c.tex, b(3) t(2) br noeqlines nogaps nolines nocons compress ///
mtitle("A" "B" "D" "E" "G" "H" "I" "J" "L" "M" "N" "O" "P" "Q" "R") ///
keep(mp_shock) stats(N) star(** 0.05 *** 0.01) replace


*-------------------------------------------------------------------------*
*-------------------------------------------------------------------------*
*-- The Role of Sectors: procyclicality, composition of the labor force --*
*-------------------------------------------------------------------------*
*-------------------------------------------------------------------------*

corr decile_actif occupation sector typecontrat if sample==1

gen flexible = 0
replace flexible = 1 if typecontrat!=4
gen worker = 0
replace worker = 1 if occupation==2 | occupation==3

*-----------------------------------------------------*
*----- Sectors with High/Low Capital Intensity -------*
*-----------------------------------------------------*

*intK3=immo_corp_brut/(massesalariale+immo_corp_brut)

egen median_intK3 = median(avg_intK3) if sector!=14
sum median_intK3

graph bar avg_intK3 if sector!=14 & avg_intK3!=., over(sector) yline(.46) ///
ylabel(#6, angle(horiz) labsize(small)) yscale(titlegap(*+5)) ytitle("Capital intensity") ///
graphregion(fcolor(white) lcolor(white)) plotregion(fcolor(white) lcolor(black)) ///
aspectratio(1) scale(*1.2) xsize(4.5) ysize(4)
graph export "FigA2_CapInt.png", width(1800) height(1600) replace
graph export "FigA2_CapInt.eps", replace

*** In % of average income
sum base_income if decile_actif!=. & sample==1 & changing_sector==0 & avg_intK3>median_intK3	
global mean_all = r(mean)
sum base_income if decile_actif<=4 & sample==1 & changing_sector==0 & avg_intK3>median_intK3	
global mean_b40 = r(mean)			
sum base_income if decile_actif>=5 & decile_actif<=8 & sample==1 & changing_sector==0 & avg_intK3>median_intK3
global mean_m40 = r(mean)
sum base_income if decile_actif>=9 & decile_actif!=. & sample==1 & changing_sector==0 & avg_intK3>median_intK3
global mean_t20 = r(mean)
cap drop above_*
gen above_all = AC0labor*100/$mean_all if decile_actif!=. & sample==1 & changing_sector==0 & avg_intK3>median_intK3
gen above_b40 = AC0labor*100/$mean_b40 if decile_actif<=4 & sample==1 & changing_sector==0 & avg_intK3>median_intK3
gen above_m40 = AC0labor*100/$mean_m40 if decile_actif>=5 & decile_actif<=8 & sample==1 & changing_sector==0 & avg_intK3>median_intK3
gen above_t20 = AC0labor*100/$mean_t20 if decile_actif>=9 & decile_actif!=. & sample==1 & changing_sector==0 & avg_intK3>median_intK3
//
sum base_income if decile_actif!=. & sample==1 & changing_sector==0 & avg_intK3<=median_intK3	
global mean_all = r(mean)
sum base_income if decile_actif<=4 & sample==1 & changing_sector==0 & avg_intK3<=median_intK3	
global mean_b40 = r(mean)			
sum base_income if decile_actif>=5 & decile_actif<=8 & sample==1 & changing_sector==0 & avg_intK3<=median_intK3
global mean_m40 = r(mean)
sum base_income if decile_actif>=9 & decile_actif!=. & sample==1 & changing_sector==0 & avg_intK3<=median_intK3
global mean_t20 = r(mean)
cap drop below_*
gen below_all = AC0labor*100/$mean_all if decile_actif!=. & sample==1 & changing_sector==0 & avg_intK3<=median_intK3
gen below_b40 = AC0labor*100/$mean_b40 if decile_actif<=4 & sample==1 & changing_sector==0 & avg_intK3<=median_intK3
gen below_m40 = AC0labor*100/$mean_m40 if decile_actif>=5 & decile_actif<=8 & sample==1 & changing_sector==0 & avg_intK3<=median_intK3
gen below_t20 = AC0labor*100/$mean_t20 if decile_actif>=9 & decile_actif!=. & sample==1 & changing_sector==0 & avg_intK3<=median_intK3
//
eststo clear
eststo: quiet reg above_all mp_shock if decile_actif!=. & sample==1 & changing_sector==0 & avg_intK3>median_intK3, vce(clus id)
eststo: quiet reg above_b40 mp_shock if decile_actif<=4 & sample==1 & changing_sector==0 & avg_intK3>median_intK3, vce(clus id)
eststo: quiet reg above_m40 mp_shock if decile_actif>=5 & decile_actif<=8 & sample==1 & changing_sector==0 & avg_intK3>median_intK3, vce(clus id)
eststo: quiet reg above_t20 mp_shock if decile_actif>=9 & decile_actif!=. & sample==1 & changing_sector==0 & avg_intK3>median_intK3, vce(clus id)
eststo: quiet reg below_all mp_shock if decile_actif!=. & sample==1 & changing_sector==0 & avg_intK3<=median_intK3, vce(clus id)
eststo: quiet reg below_b40 mp_shock if decile_actif<=4 & sample==1 & changing_sector==0 & avg_intK3<=median_intK3, vce(clus id)
eststo: quiet reg below_m40 mp_shock if decile_actif>=5 & decile_actif<=8 & sample==1 & changing_sector==0 & avg_intK3<=median_intK3, vce(clus id)
eststo: quiet reg below_t20 mp_shock if decile_actif>=9 & decile_actif!=. & sample==1 & changing_sector==0 & avg_intK3<=median_intK3, vce(clus id)
esttab, nocons compress keep(mp_shock) star(** 0.05 *** 0.01)
esttab using Tab5a.tex, b(3) t(2) br noeqlines nogaps nolines nocons compress keep(mp_shock) star(** 0.05 *** 0.01) replace

*-----------------------------------------------*
*----- Sectors with High/Low Endettement -------*
*-----------------------------------------------*

*lev=endettement_brut/actifs

egen median_lev = median(avg_lev) if sector!=14
sum median_lev

graph bar avg_lev if sector!=14 & avg_lev!=., over(sector) yline(.26) ///
ylabel(#6, angle(horiz) labsize(small)) yscale(titlegap(*+5)) ytitle("Leverage") ///
graphregion(fcolor(white) lcolor(white)) plotregion(fcolor(white) lcolor(black)) ///
aspectratio(1) scale(*1.2) xsize(4.5) ysize(4)
graph export "FigA2_Lev.png", width(1800) height(1600) replace
graph export "FigA2_Lev.eps", replace

*** In % of average income
sum base_income if decile_actif!=. & sample==1 & changing_sector==0 & avg_lev>median_lev	
global mean_all = r(mean)
sum base_income if decile_actif<=4 & sample==1 & changing_sector==0 & avg_lev>median_lev	
global mean_b40 = r(mean)			
sum base_income if decile_actif>=5 & decile_actif<=8 & sample==1 & changing_sector==0 & avg_lev>median_lev
global mean_m40 = r(mean)
sum base_income if decile_actif>=9 & decile_actif!=. & sample==1 & changing_sector==0 & avg_lev>median_lev
global mean_t20 = r(mean)
cap drop above_*
gen above_all = AC0labor*100/$mean_all if decile_actif!=. & sample==1 & changing_sector==0 & avg_lev>median_lev
gen above_b40 = AC0labor*100/$mean_b40 if decile_actif<=4 & sample==1 & changing_sector==0 & avg_lev>median_lev
gen above_m40 = AC0labor*100/$mean_m40 if decile_actif>=5 & decile_actif<=8 & sample==1 & changing_sector==0 & avg_lev>median_lev
gen above_t20 = AC0labor*100/$mean_t20 if decile_actif>=9 & decile_actif!=. & sample==1 & changing_sector==0 & avg_lev>median_lev
//
sum base_income if decile_actif!=. & sample==1 & changing_sector==0 & avg_lev<=median_lev	
global mean_all = r(mean)	
sum base_income if decile_actif<=4 & sample==1 & changing_sector==0 & avg_lev<=median_lev	
global mean_b40 = r(mean)			
sum base_income if decile_actif>=5 & decile_actif<=8 & sample==1 & changing_sector==0 & avg_lev<=median_lev
global mean_m40 = r(mean)
sum base_income if decile_actif>=9 & decile_actif!=. & sample==1 & changing_sector==0 & avg_lev<=median_lev
global mean_t20 = r(mean)
cap drop below_*
gen below_all = AC0labor*100/$mean_all if decile_actif!=. & sample==1 & changing_sector==0 & avg_lev<=median_lev
gen below_b40 = AC0labor*100/$mean_b40 if decile_actif<=4 & sample==1 & changing_sector==0 & avg_lev<=median_lev
gen below_m40 = AC0labor*100/$mean_m40 if decile_actif>=5 & decile_actif<=8 & sample==1 & changing_sector==0 & avg_lev<=median_lev
gen below_t20 = AC0labor*100/$mean_t20 if decile_actif>=9 & decile_actif!=. & sample==1 & changing_sector==0 & avg_lev<=median_lev
//
eststo clear
eststo: quiet reg above_all mp_shock if decile_actif!=. & sample==1 & changing_sector==0 & avg_lev>median_lev, vce(clus id)
eststo: quiet reg above_b40 mp_shock if decile_actif<=4 & sample==1 & changing_sector==0 & avg_lev>median_lev, vce(clus id)
eststo: quiet reg above_m40 mp_shock if decile_actif>=5 & decile_actif<=8 & sample==1 & changing_sector==0 & avg_lev>median_lev, vce(clus id)
eststo: quiet reg above_t20 mp_shock if decile_actif>=9 & decile_actif!=. & sample==1 & changing_sector==0 & avg_lev>median_lev, vce(clus id)
eststo: quiet reg below_all mp_shock if decile_actif!=. & sample==1 & changing_sector==0 & avg_lev<=median_lev, vce(clus id)
eststo: quiet reg below_b40 mp_shock if decile_actif<=4 & sample==1 & changing_sector==0 & avg_lev<=median_lev, vce(clus id)
eststo: quiet reg below_m40 mp_shock if decile_actif>=5 & decile_actif<=8 & sample==1 & changing_sector==0 & avg_lev<=median_lev, vce(clus id)
eststo: quiet reg below_t20 mp_shock if decile_actif>=9 & decile_actif!=. & sample==1 & changing_sector==0 & avg_lev<=median_lev, vce(clus id)
esttab, nocons compress keep(mp_shock) star(** 0.05 *** 0.01)
esttab using Tab5b.tex, b(3) t(2) br noeqlines nogaps nolines nocons compress keep(mp_shock) star(** 0.05 *** 0.01) replace

*-----------------------------------------------------------*
*-- Sectors with High/Low permanent contract (CDI) ---------*
*-----------------------------------------------------------*

bysort sector: egen mean_flex = mean(flexible) if sector!=14
egen median_flex = median(mean_flex) if sector!=14
sum median_flex

graph bar mean_flex if sector!=14 & mean_flex!=. & sector!=21, over(sector) yline(.26) ///
ylabel(#6, angle(horiz) labsize(small)) yscale(titlegap(*+5)) ytitle("Share of flexible contracts") ///
graphregion(fcolor(white) lcolor(white)) plotregion(fcolor(white) lcolor(black)) ///
aspectratio(1) scale(*1.2) xsize(4.5) ysize(4)
graph export "FigA2_Flex.png", width(1800) height(1600) replace
graph export "FigA2_Flex.eps", replace

*** In % of average income
sum base_income if decile_actif!=. & sample==1 & changing_sector==0 & mean_flex>median_flex	
global mean_all = r(mean)
sum base_income if decile_actif<=4 & sample==1 & changing_sector==0 & mean_flex>median_flex	
global mean_b40 = r(mean)			
sum base_income if decile_actif>=5 & decile_actif<=8 & sample==1 & changing_sector==0 & mean_flex>median_flex
global mean_m40 = r(mean)
sum base_income if decile_actif>=9 & decile_actif!=. & sample==1 & changing_sector==0 & mean_flex>median_flex
global mean_t20 = r(mean)
cap drop above_*
gen above_all = AC0labor*100/$mean_all if decile_actif!=. & sample==1 & changing_sector==0 & mean_flex>median_flex
gen above_b40 = AC0labor*100/$mean_b40 if decile_actif<=4 & sample==1 & changing_sector==0 & mean_flex>median_flex
gen above_m40 = AC0labor*100/$mean_m40 if decile_actif>=5 & decile_actif<=8 & sample==1 & changing_sector==0 & mean_flex>median_flex
gen above_t20 = AC0labor*100/$mean_t20 if decile_actif>=9 & decile_actif!=. & sample==1 & changing_sector==0 & mean_flex>median_flex
//
sum base_income if decile_actif!=. & sample==1 & changing_sector==0 & mean_flex<=median_flex	
global mean_all = r(mean)
sum base_income if decile_actif<=4 & sample==1 & changing_sector==0 & mean_flex<=median_flex	
global mean_b40 = r(mean)			
sum base_income if decile_actif>=5 & decile_actif<=8 & sample==1 & changing_sector==0 & mean_flex<=median_flex
global mean_m40 = r(mean)
sum base_income if decile_actif>=9 & decile_actif!=. & sample==1 & changing_sector==0 & mean_flex<=median_flex
global mean_t20 = r(mean)
cap drop below_*
gen below_all = AC0labor*100/$mean_all if decile_actif!=. & sample==1 & changing_sector==0 & mean_flex<=median_flex
gen below_b40 = AC0labor*100/$mean_b40 if decile_actif<=4 & sample==1 & changing_sector==0 & mean_flex<=median_flex
gen below_m40 = AC0labor*100/$mean_m40 if decile_actif>=5 & decile_actif<=8 & sample==1 & changing_sector==0 & mean_flex<=median_flex
gen below_t20 = AC0labor*100/$mean_t20 if decile_actif>=9 & decile_actif!=. & sample==1 & changing_sector==0 & mean_flex<=median_flex
//
eststo clear
eststo: quiet reg above_all mp_shock if decile_actif!=. & sample==1 & changing_sector==0 & mean_flex>median_flex, vce(clus id)
eststo: quiet reg above_b40 mp_shock if decile_actif<=4 & sample==1 & changing_sector==0 & mean_flex>median_flex, vce(clus id)
eststo: quiet reg above_m40 mp_shock if decile_actif>=5 & decile_actif<=8 & sample==1 & changing_sector==0 & mean_flex>median_flex, vce(clus id)
eststo: quiet reg above_t20 mp_shock if decile_actif>=9 & decile_actif!=. & sample==1 & changing_sector==0 & mean_flex>median_flex, vce(clus id)
eststo: quiet reg below_all mp_shock if decile_actif!=. & sample==1 & changing_sector==0 & mean_flex<=median_flex, vce(clus id)
eststo: quiet reg below_b40 mp_shock if decile_actif<=4 & sample==1 & changing_sector==0 & mean_flex<=median_flex, vce(clus id)
eststo: quiet reg below_m40 mp_shock if decile_actif>=5 & decile_actif<=8 & sample==1 & changing_sector==0 & mean_flex<=median_flex, vce(clus id)
eststo: quiet reg below_t20 mp_shock if decile_actif>=9 & decile_actif!=. & sample==1 & changing_sector==0 & mean_flex<=median_flex, vce(clus id)
esttab, nocons compress keep(mp_shock) star(** 0.05 *** 0.01)
esttab using Tab5c.tex, b(3) t(2) br noeqlines nogaps nolines nocons compress keep(mp_shock) star(** 0.05 *** 0.01) replace

*---------------------------------------------------------------*
*-------- Sectors with High/Low blue-collar (Ouvrier ) ---------*
*---------------------------------------------------------------*

bysort sector: egen mean_worker = mean(worker) if sector!=14
egen median_worker = median(mean_worker) if sector!=14
sum median_worker

graph bar mean_worker if sector!=14 & mean_worker!=. & sector!=21, over(sector) yline(.54) ///
ylabel(#6, angle(horiz) labsize(small)) yscale(titlegap(*+5)) ytitle("Share of blue-collar workers in labor force") ///
graphregion(fcolor(white) lcolor(white)) plotregion(fcolor(white) lcolor(black)) ///
aspectratio(1) scale(*1.2) xsize(4.5) ysize(4)
graph export "FigA2_Worker.png", width(1800) height(1600) replace
graph export "FigA2_Worker.eps", replace

*** In % of average income
sum base_income if decile_actif!=. & sample==1 & changing_sector==0 & mean_worker>median_worker	
global mean_all = r(mean)	
sum base_income if decile_actif<=4 & sample==1 & changing_sector==0 & mean_worker>median_worker	
global mean_b40 = r(mean)			
sum base_income if decile_actif>=5 & decile_actif<=8 & sample==1 & changing_sector==0 & mean_worker>median_worker
global mean_m40 = r(mean)
sum base_income if decile_actif>=9 & decile_actif!=. & sample==1 & changing_sector==0 & mean_worker>median_worker
global mean_t20 = r(mean)
cap drop above_*
gen above_all = AC0labor*100/$mean_all if decile_actif!=. & sample==1 & changing_sector==0 & mean_worker>median_worker
gen above_b40 = AC0labor*100/$mean_b40 if decile_actif<=4 & sample==1 & changing_sector==0 & mean_worker>median_worker
gen above_m40 = AC0labor*100/$mean_m40 if decile_actif>=5 & decile_actif<=8 & sample==1 & changing_sector==0 & mean_worker>median_worker
gen above_t20 = AC0labor*100/$mean_t20 if decile_actif>=9 & decile_actif!=. & sample==1 & changing_sector==0 & mean_worker>median_worker
//
sum base_income if decile_actif!=. & sample==1 & changing_sector==0 & mean_worker<=median_worker	
global mean_all = r(mean)
sum base_income if decile_actif<=4 & sample==1 & changing_sector==0 & mean_worker<=median_worker	
global mean_b40 = r(mean)			
sum base_income if decile_actif>=5 & decile_actif<=8 & sample==1 & changing_sector==0 & mean_worker<=median_worker
global mean_m40 = r(mean)
sum base_income if decile_actif>=9 & decile_actif!=. & sample==1 & changing_sector==0 & mean_worker<=median_worker
global mean_t20 = r(mean)
cap drop below_*
gen below_all = AC0labor*100/$mean_all if decile_actif!=. & sample==1 & changing_sector==0 & mean_worker<=median_worker
gen below_b40 = AC0labor*100/$mean_b40 if decile_actif<=4 & sample==1 & changing_sector==0 & mean_worker<=median_worker
gen below_m40 = AC0labor*100/$mean_m40 if decile_actif>=5 & decile_actif<=8 & sample==1 & changing_sector==0 & mean_worker<=median_worker
gen below_t20 = AC0labor*100/$mean_t20 if decile_actif>=9 & decile_actif!=. & sample==1 & changing_sector==0 & mean_worker<=median_worker
//
eststo clear
eststo: quiet reg above_all mp_shock if decile_actif!=. & sample==1 & changing_sector==0 & mean_worker>median_worker, vce(clus id)
eststo: quiet reg above_b40 mp_shock if decile_actif<=4 & sample==1 & changing_sector==0 & mean_worker>median_worker, vce(clus id)
eststo: quiet reg above_m40 mp_shock if decile_actif>=5 & decile_actif<=8 & sample==1 & changing_sector==0 & mean_worker>median_worker, vce(clus id)
eststo: quiet reg above_t20 mp_shock if decile_actif>=9 & decile_actif!=. & sample==1 & changing_sector==0 & mean_worker>median_worker, vce(clus id)
eststo: quiet reg below_all mp_shock if decile_actif!=. & sample==1 & changing_sector==0 & mean_worker<=median_worker, vce(clus id)
eststo: quiet reg below_b40 mp_shock if decile_actif<=4 & sample==1 & changing_sector==0 & mean_worker<=median_worker, vce(clus id)
eststo: quiet reg below_m40 mp_shock if decile_actif>=5 & decile_actif<=8 & sample==1 & changing_sector==0 & mean_worker<=median_worker, vce(clus id)
eststo: quiet reg below_t20 mp_shock if decile_actif>=9 & decile_actif!=. & sample==1 & changing_sector==0 & mean_worker<=median_worker, vce(clus id)
esttab, nocons compress keep(mp_shock) star(** 0.05 *** 0.01)
esttab using Tab5d.tex, b(3) t(2) br noeqlines nogaps nolines nocons compress keep(mp_shock) star(** 0.05 *** 0.01) replace


*---------------------------------------------------------------*
*----------- TABLE A11 - Controlling for sector FE -------------*
*---------------------------------------------------------------*

*** Dchomage, controlling for sector:
eststo clear
eststo: quiet reg Dchomage mp_shock fe_sector_* if decile_actif!=. & sample==1, vce(clus id)
eststo: quiet reg Dchomage mp_shock fe_sector_* if decile_actif<=4 & sample==1, vce(clus id)
eststo: quiet reg Dchomage mp_shock fe_sector_* if decile_actif>=5 & decile_actif<=8 & sample==1, vce(clus id)
eststo: quiet reg Dchomage mp_shock fe_sector_* if decile_actif>=9 & decile_actif!=. & sample==1, vce(clus id)
esttab, nocons compress keep(mp_shock) star(** 0.05 *** 0.01)
esttab using TabA11a.tex, b(3) t(2) br noeqlines nogaps nolines nocons compress ///
keep(mp_shock) star(** 0.05 *** 0.01) replace

*** Effect on labor income if employed==1, controlling for sector:
sum base_income if decile_actif!=. & sample==1 & employed==1 	
global mean_all = r(mean)				
sum base_income if decile_actif<=4 & sample==1 & employed==1	
global mean_b40 = r(mean)			
sum base_income if decile_actif>=5 & decile_actif<=8 & sample==1 & employed==1 	
global mean_m40 = r(mean)
sum base_income if decile_actif>=9 & decile_actif!=. & sample==1 & employed==1 
global mean_t20 = r(mean)
cap drop intensive_*
gen intensive_all = AC0labor*100/$mean_all if decile_actif!=. & sample==1 & employed==1
gen intensive_b40 = AC0labor*100/$mean_b40 if decile_actif<=4 & sample==1 & employed==1
gen intensive_m40 = AC0labor*100/$mean_m40 if decile_actif>=5 & decile_actif<=8 & sample==1 & employed==1
gen intensive_t20 = AC0labor*100/$mean_t20 if decile_actif>=9 & decile_actif!=. & sample==1 & employed==1
//
eststo clear
eststo: quiet reg intensive_all mp_shock fe_sector_* if decile_actif!=. & sample==1 & employed==1, vce(clus id)
eststo: quiet reg intensive_b40 mp_shock fe_sector_* if decile_actif<=4 & sample==1 & employed==1, vce(clus id)
eststo: quiet reg intensive_m40 mp_shock fe_sector_* if decile_actif>=5 & decile_actif<=8 & sample==1 & employed==1, vce(clus id)
eststo: quiet reg intensive_t20 mp_shock fe_sector_* if decile_actif>=9 & decile_actif!=. & sample==1 & employed==1, vce(clus id)
esttab, nocons compress keep(mp_shock) star(** 0.05 *** 0.01)
esttab using TabA11b.tex, b(3) t(2) br noeqlines nogaps nolines nocons compress ///
keep(mp_shock) star(** 0.05 *** 0.01) replace

*---------------------------------------------------------------------------------------*
*---------------------------------------------------------------------------------------*
*------------------- SECTION 6 Other dimensions of heterogeneity -----------------------*
*---------------------------------------------------------------------------------------*
*---------------------------------------------------------------------------------------*

*--------------------------------------------------------------*
*---------------- TABLE A12 - Age + Gender --------------------*
*--------------------------------------------------------------*

*** Dchomage
eststo clear
eststo: quiet reg Dchomage mp_shock if decile_actif!=. & sample==1, vce(clus id)
eststo: quiet reg Dchomage mp_shock if decile_actif!=. & sample==1 & age16_24==1, vce(clus id)
eststo: quiet reg Dchomage mp_shock if decile_actif!=. & sample==1 & age25_34==1, vce(clus id)
eststo: quiet reg Dchomage mp_shock if decile_actif!=. & sample==1 & age35_44==1, vce(clus id)
eststo: quiet reg Dchomage mp_shock if decile_actif!=. & sample==1 & age45_54==1, vce(clus id)
eststo: quiet reg Dchomage mp_shock if decile_actif!=. & sample==1 & age55_64==1, vce(clus id)
eststo: quiet reg Dchomage mp_shock if decile_actif!=. & sample==1 & sex==1, vce(clus id)
eststo: quiet reg Dchomage mp_shock if decile_actif!=. & sample==1 & sex==2, vce(clus id)
esttab, nocons compress keep(mp_shock) star(** 0.05 *** 0.01) ///
mtitle("Baseline" "16-24" "25-34" "35-44 ""45-54" "55-64" "Men" "Women")
esttab using TabA12a.tex, b(3) t(2) br noeqlines nogaps nolines nocons compress ///
mtitle("Baseline" "16-24" "25-34" "35-44 ""45-54" "55-64" "Men" "Women") ///
keep(mp_shock) stats(N) star(** 0.05 *** 0.01) replace

*** (in % of average income)
sum base_income if decile_actif!=. & sample==1 & employed==1 	
global mean_all = r(mean)	
sum base_income if decile_actif!=. & sample==1 & employed==1 & age16_24==1	
global mean_16_24 = r(mean)	
sum base_income if decile_actif!=. & sample==1 & employed==1 & age25_34==1	
global mean_25_34 = r(mean)			
sum base_income if decile_actif!=. & sample==1 & employed==1 & age35_44==1	
global mean_35_44 = r(mean)			
sum base_income if decile_actif!=. & sample==1 & employed==1 & age45_54==1	
global mean_45_54 = r(mean)		
sum base_income if decile_actif!=. & sample==1 & employed==1 & age55_64==1	
global mean_55_64 = r(mean)
sum base_income if decile_actif!=. & sample==1 & employed==1 & sex==1	
global mean_1 = r(mean)	
sum base_income if decile_actif!=. & sample==1 & employed==1 & sex==2
global mean_2 = r(mean)					
//
cap drop intensive_*
gen intensive_all = AC0labor*100/$mean_all if decile_actif!=. & sample==1 & employed==1
gen intensive_16_24 = AC0labor*100/$mean_16_24 if decile_actif!=. & sample==1 & employed==1
gen intensive_25_34 = AC0labor*100/$mean_25_34 if decile_actif!=. & sample==1 & employed==1
gen intensive_35_44 = AC0labor*100/$mean_35_44 if decile_actif!=. & sample==1 & employed==1
gen intensive_45_54 = AC0labor*100/$mean_45_54 if decile_actif!=. & sample==1 & employed==1
gen intensive_55_64 = AC0labor*100/$mean_55_64 if decile_actif!=. & sample==1 & employed==1
gen intensive_1 = AC0labor*100/$mean_1 if decile_actif!=. & sample==1 & employed==1
gen intensive_2 = AC0labor*100/$mean_2 if decile_actif!=. & sample==1 & employed==1
//
eststo clear
eststo: quiet reg intensive_all mp_shock if decile_actif!=. & sample==1 & employed==1, vce(clus id)
eststo: quiet reg intensive_16_24 mp_shock if decile_actif!=. & sample==1 & employed==1 & age16_24==1, vce(clus id)
eststo: quiet reg intensive_25_34 mp_shock if decile_actif!=. & sample==1 & employed==1 & age25_34==1, vce(clus id)
eststo: quiet reg intensive_35_44 mp_shock if decile_actif!=. & sample==1 & employed==1 & age35_44==1, vce(clus id)
eststo: quiet reg intensive_45_54 mp_shock if decile_actif!=. & sample==1 & employed==1 & age45_54==1, vce(clus id)
eststo: quiet reg intensive_55_64 mp_shock if decile_actif!=. & sample==1 & employed==1 & age55_64==1, vce(clus id)
eststo: quiet reg intensive_1 mp_shock if decile_actif!=. & sample==1 & employed==1 & sex==1, vce(clus id)
eststo: quiet reg intensive_2 mp_shock if decile_actif!=. & sample==1 & employed==1 & sex==2, vce(clus id)
esttab, nocons compress keep(mp_shock) star(** 0.05 *** 0.01) ///
mtitle("Baseline-All" "16-24" "25-34" "35-44" "45-54" "55-64" "Men" "Women")
esttab using TabA12b.tex, b(3) t(2) br noeqlines nogaps nolines nocons compress ///
mtitle("Baseline-All" "16-24" "25-34" "35-44 ""45-54" "55-64" "Men" "Women") ///
keep(mp_shock) stats(N) star(** 0.05 *** 0.01) replace


*-----------------------------------------------------------*
*-------- TABLE A13 - Heterogeneity - Occupation -----------*
*-----------------------------------------------------------*

*** Dchomage
eststo clear
eststo: quiet reg Dchomage mp_shock if decile_actif!=. & sample==1, vce(clus id)
eststo: quiet reg Dchomage mp_shock if decile_actif!=. & sample==1 & occupation==1, vce(clus id)
eststo: quiet reg Dchomage mp_shock if decile_actif!=. & sample==1 & occupation==2, vce(clus id)
eststo: quiet reg Dchomage mp_shock if decile_actif!=. & sample==1 & occupation==3, vce(clus id)
eststo: quiet reg Dchomage mp_shock if decile_actif!=. & sample==1 & occupation==4, vce(clus id)
eststo: quiet reg Dchomage mp_shock if decile_actif!=. & sample==1 & self==1, vce(clus id)
eststo: quiet reg Dchomage mp_shock if decile_actif!=. & sample==1 & occupation==99, vce(clus id)
esttab, nocons compress keep(mp_shock) star(** 0.05 *** 0.01) ///
mtitle("All" "CatABC" "Ouv/Tech/Emp" "NCadre" "Cadre/DG")
esttab using TabA13a.tex, b(3) t(2) br noeqlines nogaps nolines nocons compress ///
mtitle("All" "CatABC" "Ouv/Tech/Emp" "NCadre" "Cadre/DG") ///
keep(mp_shock) stats(N) star(** 0.05 *** 0.01) replace

*** (in % of average income)
sum base_income if decile_actif!=. & sample==1 & employed==1 	
global mean_all = r(mean)	
sum base_income if decile_actif!=. & sample==1 & employed==1 & occupation==1	
global mean_1 = r(mean)	
sum base_income if decile_actif!=. & sample==1 & employed==1 & occupation==2	
global mean_2 = r(mean)			
sum base_income if decile_actif!=. & sample==1 & employed==1 & occupation==3	
global mean_3 = r(mean)
sum base_income if decile_actif!=. & sample==1 & employed==1 & occupation==4	
global mean_4 = r(mean)							
//
cap drop intensive_*
gen intensive_all = AC0labor*100/$mean_all if decile_actif!=. & sample==1 & employed==1
gen intensive_1 = AC0labor*100/$mean_1 if decile_actif!=. & sample==1 & employed==1
gen intensive_2 = AC0labor*100/$mean_2 if decile_actif!=. & sample==1 & employed==1
gen intensive_3 = AC0labor*100/$mean_3 if decile_actif!=. & sample==1 & employed==1
gen intensive_4 = AC0labor*100/$mean_4 if decile_actif!=. & sample==1 & employed==1
//
eststo clear
eststo: quiet reg intensive_all mp_shock if decile_actif!=. & sample==1 & employed==1, vce(clus id)
eststo: quiet reg intensive_1 mp_shock if decile_actif!=. & sample==1 & employed==1 & occupation==1, vce(clus id)
eststo: quiet reg intensive_2 mp_shock if decile_actif!=. & sample==1 & employed==1 & occupation==2, vce(clus id)
eststo: quiet reg intensive_3 mp_shock if decile_actif!=. & sample==1 & employed==1 & occupation==3, vce(clus id)
eststo: quiet reg intensive_4 mp_shock if decile_actif!=. & sample==1 & employed==1 & occupation==4, vce(clus id)
esttab, nocons compress keep(mp_shock) star(** 0.05 *** 0.01) ///
mtitle("All" "CatABC" "Ouv/Tech/Emp" "NCadre" "Cadre/DG")
esttab using TabA13b.tex, b(3) t(2) br noeqlines nogaps nolines nocons compress ///
mtitle("All" "CatABC" "Ouv/Tech/Emp" "NCadre" "Cadre/DG") ///
keep(mp_shock) stats(N) star(** 0.05 *** 0.01) replace


*-----------------------------------------------------------------*
*-------- TABLE A14 - Heterogeneity - Type of contract -----------*
*-----------------------------------------------------------------*

*** Dchomage
eststo clear
eststo: quiet reg Dchomage mp_shock if decile_actif!=. & sample==1, vce(clus id)
eststo: quiet reg Dchomage mp_shock if decile_actif!=. & sample==1 & typecontrat==1, vce(clus id)
eststo: quiet reg Dchomage mp_shock if decile_actif!=. & sample==1 & typecontrat==2, vce(clus id)
eststo: quiet reg Dchomage mp_shock if decile_actif!=. & sample==1 & typecontrat==3, vce(clus id)
eststo: quiet reg Dchomage mp_shock if decile_actif!=. & sample==1 & typecontrat==4, vce(clus id)
eststo: quiet reg Dchomage mp_shock if decile_actif!=. & sample==1 & typecontrat==99, vce(clus id)
esttab, nocons compress keep(mp_shock) star(** 0.05 *** 0.01) ///
mtitle("Baseline-All" "App/Stag/Qual" "Interim" "CDD" "CDI")
esttab using TabA14a.tex, b(3) t(2) br noeqlines nogaps nolines nocons compress ///
mtitle("Baseline-All" "App/Stag/Qual" "Interim" "CDD" "CDI") ///
keep(mp_shock) stats(N) star(** 0.05 *** 0.01) replace

*** nbmois_cho (excluding 12)
eststo clear
eststo: quiet reg nbmois_cho mp_shock if decile_actif!=. & sample==1 & nbmois_cho!=12, vce(clus id)
eststo: quiet reg nbmois_cho mp_shock if decile_actif!=. & sample==1 & typecontrat==1 & nbmois_cho!=12, vce(clus id)
eststo: quiet reg nbmois_cho mp_shock if decile_actif!=. & sample==1 & typecontrat==2 & nbmois_cho!=12, vce(clus id)
eststo: quiet reg nbmois_cho mp_shock if decile_actif!=. & sample==1 & typecontrat==3 & nbmois_cho!=12, vce(clus id)
eststo: quiet reg nbmois_cho mp_shock if decile_actif!=. & sample==1 & typecontrat==4 & nbmois_cho!=12, vce(clus id)
eststo: quiet reg nbmois_cho mp_shock if decile_actif!=. & sample==1 & typecontrat==99 & nbmois_cho!=12, vce(clus id)
esttab, nocons compress keep(mp_shock) star(** 0.05 *** 0.01) ///
mtitle("Baseline-All" "App/Stag/Qual" "Interim" "CDD" "CDI")
esttab using TabA14b.tex, b(3) t(2) br noeqlines nogaps nolines nocons compress ///
mtitle("Baseline-All" "App/Stag/Qual" "Interim" "CDD" "CDI") ///
keep(mp_shock) stats(N) star(** 0.05 *** 0.01) replace

*** (in % of average income)
sum base_income if decile_actif!=. & sample==1 & employed==1 	
global mean_all = r(mean)	
sum base_income if decile_actif!=. & sample==1 & employed==1 & typecontrat==1	
global mean_1 = r(mean)	
sum base_income if decile_actif!=. & sample==1 & employed==1 & typecontrat==2	
global mean_2 = r(mean)			
sum base_income if decile_actif!=. & sample==1 & employed==1 & typecontrat==3	
global mean_3 = r(mean)
sum base_income if decile_actif!=. & sample==1 & employed==1 & typecontrat==4	
global mean_4 = r(mean)							
//
cap drop intensive_*
gen intensive_all = AC0labor*100/$mean_all if decile_actif!=. & sample==1 & employed==1
gen intensive_1 = AC0labor*100/$mean_1 if decile_actif!=. & sample==1 & employed==1
gen intensive_2 = AC0labor*100/$mean_2 if decile_actif!=. & sample==1 & employed==1
gen intensive_3 = AC0labor*100/$mean_3 if decile_actif!=. & sample==1 & employed==1
gen intensive_4 = AC0labor*100/$mean_4 if decile_actif!=. & sample==1 & employed==1
//
eststo clear
eststo: quiet reg intensive_all mp_shock if decile_actif!=. & sample==1 & employed==1, vce(clus id)
eststo: quiet reg intensive_1 mp_shock if decile_actif!=. & sample==1 & employed==1 & typecontrat==1, vce(clus id)
eststo: quiet reg intensive_2 mp_shock if decile_actif!=. & sample==1 & employed==1 & typecontrat==2, vce(clus id)
eststo: quiet reg intensive_3 mp_shock if decile_actif!=. & sample==1 & employed==1 & typecontrat==3, vce(clus id)
eststo: quiet reg intensive_4 mp_shock if decile_actif!=. & sample==1 & employed==1 & typecontrat==4, vce(clus id)
esttab, nocons compress keep(mp_shock) star(** 0.05 *** 0.01) ///
mtitle("Baseline-All" "App/Stag/Qual" "Interim" "CDD" "CDI")
esttab using TabA14c.tex, b(3) t(2) br noeqlines nogaps nolines nocons compress ///
mtitle("Baseline-All" "App/Stag/Qual" "Interim" "CDD" "CDI") ///
keep(mp_shock) stats(N) star(** 0.05 *** 0.01) replace


